Practical examples of ejbSelect methods

Hello,
I understand ejbFindXX methods are used by ejb clients whereas ejbSelectXX methods are used by the ejb itself. Is that the difference? Can anyone give me a practical example/use of an ejbSelectXX method?
Thanks in advance,
Albert Steed

Refer to
http://www.onjava.com/pub/a/onjava/2001/09/19/ejbql.html

Similar Messages

  • Initialization Blocks -- Practical Example.

    I am curious about I topic that I have just recently learned about and would like to post it for discussion.
    Does anyone know of a practical example of the use of an initialization block? Why would one want to use an initialization block? What can be accomplished with an initialization block that you cannot accomplish with a constructor that doesn't accept any parameters?

    Hi Robert,
    Initializers are used in initialization of object and classes. They can also be used to define constants in Interfaces.
    Here I am explaning by corelating the Constructor with Initialization.
    In what order is initialization code executed? What should I put where ?
    Instance variable initialization code can go in three places within a class:
    In an instance variable initializer for a class (or a superclass).
    class C {
    String var = "val";
    In a constructor for a class (or a superclass).
    public C() { var = "val"; }
    In an object initializer block. This is new in Java 1.1; its just like a static initializer block but without the keyword static.
    { var = "val"; }
    The order of evaluation (ignoring out of memory problems) when you say new C() is:
    1.Call a constructor for C's superclass (unless C is Object, in which case it has no superclass). It will always be the no-argument constructor, unless the programmer explicitly coded super(...) as
    the very first statement of the constructor.
    2.Once the super constructor has returned, execute any instance variable initializers and object initializer blocks in textual (left-to-right) order. Don't be confused by the fact that javadoc and
    javap use alphabetical ordering; that's not important here.
    3.Now execute the remainder of the body for the constructor. This can set instance variables or do anything else.
    In general, you have a lot of freedom to choose any of these three forms. My recommendation is to use instance variable initailizers in cases where there is a variable that takes the same value
    regardless of which constructor is used. Use object initializer blocks only when initialization is complex (e.g. it requires a loop) and you don't want to repeat it in multiple constructors. Use a constructor
    for the rest.
    Here's another example:
    Program:
    class A {
    String a1 = ABC.echo(" 1: a1");
    String a2 = ABC.echo(" 2: a2");
    public A() {ABC.echo(" 3: A()");}
    class B extends A {
    String b1 = ABC.echo(" 4: b1");
    String b2;
    public B() {
    ABC.echo(" 5: B()");
    b1 = ABC.echo(" 6: b1 reset");
    a2 = ABC.echo(" 7: a2 reset");
    class C extends B {
    String c1;
    { c1 = ABC.echo(" 8: c1"); }
    String c2;
    String c3 = ABC.echo(" 9: c3");
    public C() {
    ABC.echo("10: C()");
    c2 = ABC.echo("11: c2");
    b2 = ABC.echo("12: b2");
    public class ABC {
    static String echo(String arg) {
    System.out.println(arg);
    return arg;
    public static void main(String[] args) {
    new C();
    Output:
    1: a1
    2: a2
    3: A()
    4: b1
    5: B()
    6: b1 reset
    7: a2 reset
    8: c1
    9: c3
    10: C()
    11: c2
    12: b2
    When should I use constructors, and when should I use other methods?
    The glib answer is to use constructors when you want a new object; that's what the keyword new is for. The infrequent answer is that constructors are often over-used, both in when they are called and
    in how much they have to do. Here are some points to consider
    Modifiers: As we saw in the previous question, one can go overboard in providing too many constructors. It is usually better to minimize the number of constructors, and then provide modifier
    methods, that do the rest of the initialization. If the modifiers return this, then you can create a useful object in one expression; if not, you will need to use a series of statements. Modifiers are
    good because often the changes you want to make during construction are also changes you will want to make later, so why duplicate code between constructors and methods.
    Factories: Often you want to create something that is an instance of some class or interface, but you either don't care exactly which subclass to create, or you want to defer that decision to
    runtime. For example, if you are writing a calculator applet, you might wish that you could call new Number(string), and have this return a Double if string is in floating point format, or a Long if
    string is in integer format. But you can't do that for two reasons: Number is an abstract class, so you can't invoke its constructor directly, and any call to a constructor must return a new instance
    of that class directly, not of a subclass. A method which returns objects like a constructor but that has more freedom in how the object is made (and what type it is) is called a factory. Java has no
    built-in support or conventions for factories, but you will want to invent conventions for using them in your code.
    Caching and Recycling: A constructor must create a new object. But creating a new object is a fairly expensive operation. Just as in the real world, you can avoid costly garbage collection by
    recycling. For example, new Boolean(x) creates a new Boolean, but you should almost always use instead (x ? Boolean.TRUE : Boolean.FALSE), which recycles an existing value rather than
    wastefully creating a new one. Java would have been better off if it advertised a method that did just this, rather than advertising the constructor. Boolean is just one example; you should also
    consider recycling of other immutable classes, including Character, Integer, and perhaps many of your own classes. Below is an example of a recycling factory for Numbers. If I had my choice, I
    would call this Number.make, but of course I can't add methods to the Number class, so it will have to go somewhere else.
    public Number numberFactory(String str) throws NumberFormatException {
    try {
    long l = Long.parseLong(str);
    if (l >= 0 && l < cachedLongs.length) {
    int i = (int)l;
    if (cachedLongs[i] != null) return cachedLongs;
    else return cachedLongs[i] = new Long(str);
    } else {
    return new Long(l);
    } catch (NumberFormatException e) {
    double d = Double.parseDouble(str);
    return d == 0.0 ? ZERO : d == 1.0 ? ONE : new Double(d);
    private Long[] cachedLongs = new Long[100];
    private Double ZERO = new Double(0.0);
    private Double ONE = new Double(1.0);
    We see that new is a useful convention, but that factories and recycling are also useful. Java chose to support only new because it is the simplest possibility, and the Java philosophy is to keep the
    language itself as simple as possible. But that doesn't mean your class libraries need to stick to the lowest denominator. (And it shouldn't have meant that the built-in libraries stuck to it, but alas, they
    did.)
    I have a class with six instance variables, each of which could be initialized or not. Should I write 64 constructors?
    Of course you don't need (26) constructors. Let's say you have a class C defined as follows:
    public class C { int a,b,c,d,e,f; }
    Here are some things you can do for constructors:
    1.Guess at what combinations of variables will likely be wanted, and provide constructors for those combinations. Pro: That's how it's usually done. Con: Difficult to guess correctly; lots of
    redundant code to write.
    2.Define setters that can be cascaded because they return this. That is, define a setter for each instance variable, then use them after a call to the default constructor:
    public C setA(int val) { a = val; return this; }
    new C().setA(1).setC(3).setE(5);
    Pro: This is a reasonably simple and efficient approach. A similar idea is discussed by Bjarne Stroustrop on page 156 of The Design and Evolution of C++. Con: You need to write all the little
    setters, they aren't JavaBean-compliant (since they return this, not void), they don't work if there are interactions between two values.
    3.Use the default constructor for an anonymous sub-class with a non-static initializer:
    new C() {{ a = 1; c = 3; e = 5; }}
    Pro: Very concise; no mess with setters. Con: The instance variables can't be private, you have the overhead of a sub-class, your object won't actually have C as its class (although it will still be an
    instanceof C), it only works if you have accessible instance variables, and many people, including experienced Java programmers, won't understand it. Actually, its quite simple: You are defining a
    new, unnamed (anonymous) subclass of C, with no new methods or variables, but with an initialization block that initializes a, c, and e. Along with defining this class, you are also making an
    instance. When I showed this to Guy Steele, he said "heh, heh! That's pretty cute, all right, but I'm not sure I would advocate widespread use..."
    4.You can switch to a language that directly supports this idiom.. For example, C++ has optional arguments. So you can do this:
    class C {
    public: C(int a=1, int b=2, int c=3, int d=4, int e=5);
    new C(10);
    Common Lisp has keyword arguments as well as optional arguments, so you can do this:
    (defstruct C a b c d e f) ; Defines the class
    (make-C :a 1 :c 3 :e 5) ; Construct an
    instance
    What about class initialization?
    It is important to distinguish class initialization from instance creation. An instance is created when you call a constructor with new. A class C is initialized the first time it is actively used. At that time,
    the initialization code for the class is run, in textual order. There are two kinds of class initialization code: static initializer blocks (static { ... }), and class variable initializers (static String var =
    Active use is defined as the first time you do any one of the following:
    1.Create an instance of C by calling a constructor;
    2.Call a static method that is defined in C (not inherited);
    3.Assign or access a static variable that is declared (not inherited) in C. It does not count if the static variable is initialized with a constant expression (one involving only primitive operators (like +
    or ||), literals, and static final variables), because these are initialized at compile time.
    Here is an example:
    Program:
    class A {
    static String a1 = ABC.echo(" 1: a1");
    static String a2 = ABC.echo(" 2: a2");
    class B extends A {
    static String b1 = ABC.echo(" 3: b1");
    static String b2;
    static {
    ABC.echo(" 4: B()");
    b1 = ABC.echo(" 5: b1 reset");
    a2 = ABC.echo(" 6: a2 reset");
    class C extends B {
    static String c1;
    static { c1 = ABC.echo(" 7: c1"); }
    static String c2;
    static String c3 = ABC.echo(" 8: c3");
    static {
    ABC.echo(" 9: C()");
    c2 = ABC.echo("10: c2");
    b2 = ABC.echo("11: b2");
    public class ABC {
    static String echo(String arg) {
    System.out.println(arg);
    return arg;
    public static void main(String[] args) {
    new C();
    Output:
    1: a1
    2: a2
    3: b1
    4: B()
    5: b1 reset
    6: a2 reset
    7: c1
    8: c3
    9: C()
    10: c2
    11: b2
    I hope the above will help you.
    Thanks
    Bakrudeen

  • I want to check the main diffrence in Pop up block enabled and disabled.But,i don't get any difference.Would u please help me to understand the difference using one practical example of website

    I want to check the main diffrence in Pop up block enabled and disabled.But,i don't get any difference.Would u please help me to understand the difference using one practical example of website

    Here's two popup test sites.
    http://www.kephyr.com/popupkillertest/test/index.html
    http://www.popuptest.com/

  • Doubts in XI basics..help me with some practical examples

    hi friends,
              I am new to SAP XI have some basic doubts. Answer my questions with some practical examples.
      1. what is meant by "Business System" and what is difference between client,customer,Business partner,3rd party
      2.If a small company already using some systems like Oracle or peopleSoft,if it wants to use SAP products then what steps it has to follow.
    3. SAP system means a SERVER?
    4.SAPWebAs means a server software?
    5.R/3 system comes under SAP system?
    6.XI is also one of the SAP  module..how it relates to other modules.
    7.In one organization which is using SAP modules,each module will be load in separate servers?
    8.PO(purchase order) means just looks like one HTML file..customer will fill the form and give it.like this,Combination of many files like this is one SAP module.Is it right assumption..?if so,then what is speciality SAP?
       I have an theoretical knowledge about IR and ID and SLD.what are general business transactions happens in any business ?(like who will send cotation,PO)  give some practical example for what actually happens in business?..who will do what?and what XI will do?

    Hi Murali,
    <u><b> 1.Business System</b></u>
      Business systems are logical systems that function as senders or receivers  within the SAP Exchange Infrastructure(XI).
    Before starting with any XI interface,the Business systems involved has to be configured in SLD(The SLD acts as the central information provider for all installed system components in your system landscape.)
    business system and technical system in XI
    <u><b>2.Third Party</b></u>
    http://help.sap.com/saphelp_nw04/helpdata/en/09/6beb170d324216aaf1fe2feb8ed374/frameset.htm
    eg.For the SAP system a  Bank would be a third-party which would be involved in interfaces involving exchange of data(Bill Payment by customer).
    <u><b>3.XI(Exchange Infrastructure)</b></u>
      It enables you to connect systems from different vendors (non-SAP and SAP) in different versions and implemented in different programming languages (Java, ABAP, and so on) to each other.
    Eg.If an interface involves Purchase Order sent from SAP system to the vendor(Non-SAP system)then,the vendor might expect a file.But the Data is in the IDOC(intermediate document) form with the SAP system.Here XI does the work of mapping the IDOC fields and the File fields and sends it to the vendor in the form of a file.
    In short,always the scene is Sender-XI-Receiver.
    The Sender and the Receiver depends upon the Business you are dealing with.
    <u><b>4.Business Partner</b></u>
    A person, organization, group of persons, or group of organizations in which a company has a business interest.
    This can also be a person, organization or group within this company.
    Examples:
    Mrs. Lisa Miller
    Maier Electricals Inc.
    Purchasing department of Maier Electricals Inc.
    <u><b>5.Client</b></u>
    http://help.sap.com/saphelp_nw04/helpdata/en/6c/a74a3735a37273e10000009b38f839/frameset.htm
    <u><b>6.SAP System</b></u>
    http://help.sap.com/saphelp_nw04/helpdata/en/33/1f4f40c3fc0272e10000000a155106/frameset.htm
    <u><b>7.SAP WebAS</b></u>
    https://www.sdn.sap.com/irj/sdn/advancedsearch?query=sapwebapplication+server&cat=sdn_all
    As you are a beginner, I understand you musn’t be aware of where to search what.
    For all details search out in http://help.sap.com
    And sdn(key in keyword in Search tab).
    You will get list of forums,blogs,documentation answering all your queries.

  • Is that a good practice to use syncronize methods for application scope cls

    Is that a good practice to use synchronize method in a application scope class, so I have a doubt, there a is class A, it has application scope and it contains a synchronized method add, so because of some network traffic or any unexpected exception client1 got stuck in the method, will that add method available for any other client...?
    Edited by: navaneeth.j on Dec 17, 2009 4:02 AM
    Edited by: navaneeth.j on Dec 17, 2009 4:04 AM

    If it needs synchronization, then it probably doesn't belong in the application scope. Either keep it as is, or reconsider the scope, or make it static.

  • Practical example of the SessionSynchronization interface

    Hello,
    Can anyone give me a practical example of use of the SessionSynchronization interface please?
    Thanks in advance,
    Julien Martin.

    just hoping will answer my question. Reactivaing my thread;
    Julien.

  • Can anyone please find me examples of these methods.......

    I'm trying to get a better idea what "Helper methods" do but cannot find any good examples, can anyone please find me examples of these method.
    Also how do I print methods between different classes in a program??
    many thanks

    Also how do I print methods between differentclasses
    in a program??This question makes no sense to me.I've got some classes that need to print methods from
    an input/output class, what code is needed for
    this????You want to print methods? You might use Reflection for this. An Input/Output class? What is that? You want to print method signatures from a class that handles IO? Why should it matter what the class does?
    I've no idea what code might be needed to do whatever it is you are wanting to do here - please clarify and see if we can get a more useful answer.

  • Can anyone provide a practical example of when Etherchannel would be configured but then NOT trunked...

    I am in the process of educating a client of mine about all aspects of switching.
    I was teaching them about Etherchannel the other day, when I realized that I did not know for sure whether or not one could create an Etherchannel and then not trunk it.
    Based on some examples I have seen, I am still led to believe it is possible.
    I am just trying to think of a practical example of configuring such...  The only thing that comes to my mind is if you are NIC teaming a server's two NIC's then we may want to Etherchannel but not trunk?...
    Thanks in Advance!

    Disclaimer
    The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
    Liability Disclaimer
    In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
    Posting
    Another example would be a p2p link between two L3 switches.

  • Practical examples for SAP BI

    Hi BI-experts!
    Can some one please recommend some practical examples/case studies to gain practical experience with SAP BI?
    - Data modelling/procurement and Reporting
    - Integrated Planing
    - BW based Consolidation
    Also other web sources, SAP books will be very appreciated.
    I already went through the first example "From the Data Model to the BI Application in
    the Web" and SAP courses SAP BW305 and 310.
    Any helpful information will be very appreciated.
    Thank you very much!
    regards
    Thom

    Hi,
    I suggest first you go through the what is BI? then where it is used, which scenario BI is usually required, for that go through this links,
    BI platform:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/42/594e3c6bf4233fe10000000a114084/frameset.htm
    DTPs:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/42/fb8ed8481e1a61e10000000a422035/frameset.htm
    Extractions in BI
    https://www.sdn.sap.com/irj/sdn/wiki
    transport
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b5/1d733b73a8f706e10000000a11402f/frameset.htm
    Difference BI and BW
    /people/sap.user72/blog/2004/11/01/sap-bi-versus-sap-bw-what146s-in-a-name
    SAP (NetWeaver) BI versus SAP BW: The Sequel
    What's new in SAP NetWeaver 7.0(2004s)? - An introduction to the functionality deltas and major changes
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/910aa7a7-0b01-0010-97a5-f28be23697d3
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4487dd91-0b01-0010-eba1-bcd6419
    http://help.sap.com/saphelp_nw04/helpdata/en/b2/e50138fede083de10000009b38f8cf/content.htm
    Hope it will help you.
    Thanks & Regards,
    SD

  • Failed to create ejbSelect method (9.0.3)

    Creating a simple ejbSelect method without any parameters failed with :
    Auto-deploying ejb (Classes were updated)... Error: null
    java.lang.NullPointerException
    void com.evermind.server.ejb.compilation.SelectMethodCompilation.compile
    void com.evermind.server.ejb.compilation.CMPObjectCompilation.verifyMeth
    ods()
    void com.evermind.server.ejb.compilation.CMPObjectCompilation.<init>(jav
    a.lang.String, com.evermind.server.ejb.compilation.Compilation, com.evermind.ser
    ver.ejb.deployment.PrimaryKeyContext, java.lang.Class, com.evermind.server.ejb.d
    atabase.DatabaseSchema)
    void com.evermind.server.ejb.compilation.PersistenceManagerCompilation.<
    init>(com.evermind.server.ejb.compilation.EntityBeanCompilation)
    void com.evermind.server.ejb.compilation.EntityBeanCompilation.<init>(co
    m.evermind.server.ejb.compilation.Compilation, com.evermind.server.ejb.deploymen
    t.EntityBeanDescriptor, boolean)
    void com.evermind.server.ejb.compilation.Compilation.compile()
    void com.evermind.server.ejb.EJBContainer.postInit(com.evermind.server.e
    jb.EJBContainerConfig, com.evermind.server.administration.ApplicationInstallatio
    n)
    void com.evermind.server.Application.postInit(com.evermind.server.Applic
    ationConfig, com.evermind.server.administration.ApplicationInstallation)
    void com.evermind.server.Application.setConfig(com.evermind.server.Appli
    cationConfig, com.evermind.server.administration.ApplicationInstallation)
    void com.evermind.server.ApplicationServer.addApplication(com.evermind.s
    erver.ApplicationConfig, com.evermind.server.Application, com.evermind.server.ad
    ministration.ApplicationInstallation)
    void com.evermind.server.ApplicationServer.initializeApplications()
    void com.evermind.server.ApplicationServer.setConfig(com.evermind.server
    .ApplicationServerConfig)
    void com.evermind.server.ApplicationServerLauncher.run()
    void java.lang.Thread.run()
    void com.evermind.util.ThreadPoolThread.run()
    Error compiling D:\servers\Oracle\903pre\j2ee\home\applications\beans\ejb: null
    Did someone successfuly test this EJB 2.0 feature on oracle 9.0.3 ?

    Can you please do a java -jar oc4j.jar -version and tell me the exact version/build# for the version you are using ?
    regards
    Debu

  • Can anyone give an example for 'PUT' method.

    Can anyone give an example for 'PUT' method ?
    Unable to find an examples for this in the forum
    Thanks
    Chandran

    Hi Chandran,
    Check link below:
    RESRful POST method
    Resource Templates : Strategy for dealing with PUT and POST
    HTH
    Zack

  • XML - Practical Example?

    Hello,
    I've read some articles on XML, and it seems to be popular, but I really am not sure why. I fail to see it's practical use.
    For example, can I use XML to create a config file for my java application? Is this a practical use? Why not just use a text file?
    Can someone describe some simple and practical examples of XML use? If it is something that will improve my knowledge and skill set, I'd like to learn it, but I don't yet see it's value, despite reading a lot about.
    For example... I need a config file for an application that contains info like this:
    [CATEGORIES]
    GUNS
    SHIELDS
    CAPACITORS
    [GUNS]
    Lasers
    Particle
    Projectile
    Etc...
    Is an XML file a good idea for creating this type of config file?
    Thanks

    You need to pass data including integers and floating point numbers between AS400, Solaris and windows. The producer is any of the three and the consumer is any of the three. Each application on each OS uses some but not all of the data. Version 2 will be adding more fields and the developement teams for each application live in different countries. Finally the project times lines for each application do not line up (some applications will be placed into production before the others are out of the coding phase.)
    Or alternatively just to keep the programmers happy. Which is always a good thing.

  • CMIR - Practical example

    Can anyone give a practical example (with real names) of a customer material info record creation.
    I want an example of a material .... what does the customers call it ... and what does the company call it internally..
    Thanks and would appreciate if i only get the practical names.....i am not looking at theoritical working of CMIR.
    Thanks again

    Dear Arijeet
    CMIR is mainly used (according to me) in Automotive Industries where the OEMs (Original Equipment Manufacturers) like Hyundai, Maruthi etc., have their own part reference and they will insist their Vendors to show this part in all official documents.  In fact, almost all OEMs will process payment only if the manufacturers billing document shows their part reference.
    Practically, manufacturer will have their own part code for various reasons like differentiating the components at each stage like whether it is an inhouse process component or boughtout component etc.,  So over a period of time, just by going through the material code itself, they will be able to tell whether the nature of component (inhouse or boughtout).
    Here they cannot just like that adhere to customer's requirement but at the sametime, in order to satisfy customer requirement, they will maintain both manufacturers part number and customer part number in CMIR and while printing, they have to define a logic in such a way that only Customer material code should fetch from VD52.
    Similarly, in terms of description also this is applicable.
    For a few products manufactured in India by a manufacturer, they call it as autoparts whereas the overseas customer calls it as Internal Combustion Engine parts.
    Hoping that I have understood your question correctly and explained the above.  If this is not what you had asked for, then please brief once again.
    thanks
    G. Lakshmipathi

  • Where get examples of the ejbSelect METHOD and Home interface method use ?

     

    Hi,
    The UI Framework has a generic M-Getter which retrives the label from DDIC. However, you can overwrite the M-Getter to return any other label. But if you define a label in Design Layer, the framework will take the label from Design Layer instead from M-Getter. And if you define a label in Configuration, the framework will take the label from the configuration instead from Design Layer.
    A-Getter is meant to be used for showing or hiding field based on Switch ID. If you see the return parameter, it returns also switch ID. Using A-Getter to showing and hiding field not based on Switch ID is not recommended.
    You were right. A-Getter is already exists in CRM 7.0 but it is not used. It is used for the Enhancement Package release of CRM.
    Regards,
    Steve

  • 'Best practice' - separating packages, classes, methods.

    I'm writing a few tools for handling classical propositional logic sentences.
    I currently have a parser (using JavaCC)
    Various reasoning methods (e.g. finding whether sentences are satisfiable or a contradition, whether two sentences are equivalent, converting to conjunctive/disjunctive normal form etc.)
    I can export/import sentences to/from XML
    I'm now coming to a tidying up stage. I'm using Eclipse 3.3 and within the project have 4 packages: logic, parser, xml, testing.
    The tree data structures are created using the JavaCC parser - because I want to leave the JavaCC generated code alone as much as possible I've created a 'LogicOperations' class containing the methods.
    I also have an 'Interpretation' class that holds a TRUE/FALSE value for each atom, e.g. if storing an example where a sentence is satisfiable (= evaluates to true).
    Most of the methods that take an Interpretation as an argument are held inside the 'LogicOperations' class too currently.
    So in a test class I might have
    LogicParser parser = new LogicParser(new StringReader("a | (b & c) => !d"));
    SimpleNode root = parser.query();
    //displays the above String in it's tree form
    root.dump();
    // List atoms in sentence
    System.out.println(Arrays.toString(LogicOperations.identifyAtoms(root)));
    // Show models (interpretations where sentence is TRUE)
    LogicOperations.printInterpretations(LogicOperations.models(root));
    // is the sentence satisfiable?
    System.out.println("Satisfiable: " + LogicOperations.isSatisfiable(root));
    // is the sentence a contradiction?
    System.out.println("Contradiction: " + LogicOperations.isContradiction(root));
    // Is the sentence consistent (a tautology)
    System.out.println("Consistent: " + LogicOperations.isConsistent(root));
    System.out.println("CNF: " + LogicOperations.printCNF(root));
    System.out.println("DNF: " + LogicOperations.printDNF(root));Question is - does separating out methods, classes and packages in this way seem the 'correct' way of doing things? It works, which is nice... but is it sloppy, lazy, bad practice, you name it...
    If any example code is worth seeing let me know, but I'm mainly after advice before I go about tidying the code up.
    Thanks in advance
    Duncan

    eknight wrote:
    My intuition would be to be able to call:
    root.isSatisfiable()Instead of having to go through a helper Method. The Functionality could still remain in LogicOperations, but I would encapsulate it all in the SimpleNode Class.
    - Just MHOThe SimpleNode class is one of a number of classes generated by JavaCC. My thinking was that if there are any modifications to the grammar then SimpleNode would be regenerated and the additional methods would need to be added back in, whereas if they're in a separate class it would mean I wouldn't have to worry about it. In the same vein, I have the eval() method separate from SimpleNode, and most other methods rely on it for their output.
    public static Boolean eval(SimpleNode root, Interpretation inter) {
         Boolean val = null;
         SimpleNode left = null;
         SimpleNode right = null;
         switch (root.jjtGetNumChildren()) {
         case 1:
              left = root.jjtGetChild(0);
              right = null;
              break;
         case 2:
              left = root.jjtGetChild(0);
              right = root.jjtGetChild(1);
              break;
         default:
              break;
         switch (root.getID()) {
         case LogicParserTreeConstants.JJTROOT:
              val = eval(left, inter);
              break;
         case LogicParserTreeConstants.JJTVOID:
              val = null;
              break;
         case LogicParserTreeConstants.JJTCOIMP:
              val = (eval(left, inter) == eval(right, inter));
              break;
         case LogicParserTreeConstants.JJTIMP:
              val = (!eval(left, inter) || eval(right, inter));
              break;
         case LogicParserTreeConstants.JJTOR:
              val = (eval(left, inter) || eval(right, inter));
              break;
         case LogicParserTreeConstants.JJTAND:
              val = (eval(left, inter) && eval(right, inter));
              break;
         case LogicParserTreeConstants.JJTNOT:
              val = !eval(left, inter);
              break;
         case LogicParserTreeConstants.JJTATOM:
              val = inter.get(root.getLabel());
              break;
         case LogicParserTreeConstants.JJTCONSTFALSE:
              val = false;
              break;
         case LogicParserTreeConstants.JJTCONSTTRUE:
              val = true;
              break;
         default:
              val = null;
              break;
         return val;
    }

Maybe you are looking for

  • Question about warranty extension

    Hi I got my satellite pro from UK, but I am not residing there. I am trying to buy warranty extension, but all the sites require UK credit card address. I contacted reseller in Egypt who said that I have to buy it from UK not Egypt, is it true? and h

  • Problem with restore in Backup.app

    I just bought a new external hard disk and did a full back up using Backup.app. Then I needed to restore my iPhoto libary and here's what I got. Restore failed. Here's the log. Begin restore at 2007-03-01 01:04:33 +0900 Created alias at /Users/ronbel

  • After pushing updates to server having issue with an automatic install.

    I am running SCCM 2012 and I am able to deploy updates to a server but for some reason want to install 7 days from today. I specifically said in the deployment to push AND install as soon as possible, what am I missing?

  • FDM validate issue

    Hi, I am loading data from FDM to HFM. I notice during Validate ste, data is getting round off. for eg: 13.12 is rounding off to 13.10 and 504.55 is rounded to 504.60. Do we have any setting in FDM to make sure data gets loaded as it is to HFM withou

  • Integration of Documentum with ESO

    Hi, Can someone please provide pointers for integration of ESO with Documentum. Regards, Himanshu