com.fdsapi.arrays
Class ConditionalCompositeContainer

java.lang.Object
  |
  +--com.fdsapi.arrays.ConditionalCompositeContainer
All Implemented Interfaces:
Conditional, ConditionalComposite

public class ConditionalCompositeContainer
extends java.lang.Object
implements ConditionalComposite

This class is used to build the ArrayFilter and ArraySQL classes (ArraySQL is simply backed by ArrayFilter). This class validates the given sql. This class does not need to be used directly by developers. All classes that implement the ConditionalComposite interface implement the ConditionalComposite design pattern.

View Code


Constructor Summary
ConditionalCompositeContainer()
           
ConditionalCompositeContainer(ConditionalComposite rootComposite)
          Contructor that takes an explicit ConditionalComposite (typically ConditionalCompositeOr) as the root (i.e.
 
Method Summary
 void addAnd()
          Add a logical "and" between Conditionals in the active ConditionalComposite
 void addConditional(Conditional conditional)
          Add a Conditional to the currently active ConditionalComposite.
 void addConditionalComposite(ConditionalComposite comp)
          This adds the ConditionalComposite to the chain AND makes it the active ConditionalComposite to which all subsequent Conditionals are added to until the paren level changes.
 void addLeftParen()
          Add a left paren to group Conditionals together.
 void addNot()
          Negate the value of the active ConditionalComposite
 void addOr()
          Add a logical "or" between Conditionals in the active ConditionalComposite
 void addRightParen()
          Add a right paren to end the current grouping of Conditionals together.
 void build()
          This method is called to convert ArrayFilter calls such as addConditional that build the object structure that implements ArrayFilter.
 java.lang.String getType()
          Empty implementation
 boolean isTrue(java.lang.Object[] row)
          This method calls the root composites isTrue(...) method and it in turn calls all Conditionals that are contained's isTrue(...) methods.
 java.lang.String toString()
          Display a string representation of all Conditionals owned by this ConditionalComposite
 void validate()
          Method that validates the syntax of the ArraySQL or ArrayFilter method calls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConditionalCompositeContainer

public ConditionalCompositeContainer()

ConditionalCompositeContainer

public ConditionalCompositeContainer(ConditionalComposite rootComposite)
Contructor that takes an explicit ConditionalComposite (typically ConditionalCompositeOr) as the root (i.e. first composite) in the chain.

Method Detail

build

public void build()
This method is called to convert ArrayFilter calls such as addConditional that build the object structure that implements ArrayFilter. It uses a WhereClauseTokens object to get a list of instructions that aid in building the backing structure. This was done so testing was easier.


isTrue

public boolean isTrue(java.lang.Object[] row)
This method calls the root composites isTrue(...) method and it in turn calls all Conditionals that are contained's isTrue(...) methods. This allows each Conditional to vote whether the row should be kept. Any Conditional that votes false can cause the row to be rejected.

Specified by:
isTrue in interface ConditionalComposite

validate

public void validate()
Method that validates the syntax of the ArraySQL or ArrayFilter method calls. It will throw a RuntimeException if there is an error such as unmatched parens


addConditional

public void addConditional(Conditional conditional)
Add a Conditional to the currently active ConditionalComposite. The active Composite is based on the current paren level.

Specified by:
addConditional in interface ConditionalComposite

addConditionalComposite

public void addConditionalComposite(ConditionalComposite comp)
This adds the ConditionalComposite to the chain AND makes it the active ConditionalComposite to which all subsequent Conditionals are added to until the paren level changes.


addLeftParen

public void addLeftParen()
Add a left paren to group Conditionals together. The implementation of this mehtod is to create a ConditionalCompositeOr object and make it the active ConditionalComposite that all subsequent Conditionals are added to until the right paren is added. Then the previous ConditionalComposite will become active.


addRightParen

public void addRightParen()
Add a right paren to end the current grouping of Conditionals together. The implementation of Then the previous ConditionalComposite becomes active.


addNot

public void addNot()
Negate the value of the active ConditionalComposite

Specified by:
addNot in interface ConditionalComposite

addAnd

public void addAnd()
Add a logical "and" between Conditionals in the active ConditionalComposite


addOr

public void addOr()
Add a logical "or" between Conditionals in the active ConditionalComposite


getType

public java.lang.String getType()
Empty implementation

Specified by:
getType in interface Conditional

toString

public java.lang.String toString()
Display a string representation of all Conditionals owned by this ConditionalComposite

Overrides:
toString in class java.lang.Object