com.metamatrix.query.sql.lang
Class CompoundCriteria

java.lang.Object
  extended by com.metamatrix.query.sql.lang.Criteria
      extended by com.metamatrix.query.sql.lang.LogicalCriteria
          extended by com.metamatrix.query.sql.lang.CompoundCriteria
All Implemented Interfaces:
LanguageObject, java.io.Serializable, java.lang.Cloneable

public class CompoundCriteria
extends LogicalCriteria

This class represents a compound criteria for logical expressions. A logical expression involves one or more criteria and a logical operator. The valid operators are "AND" and "OR".

See Also:
Serialized Form

Field Summary
static int AND
          Constant indicating the logical "and" of two or more criteria.
static int OR
          Constant indicating the logical "or" of two or more criteria.
 
Constructor Summary
CompoundCriteria()
          Constructs a default instance of this class.
CompoundCriteria(int operator, Criteria left, Criteria right)
          Constructs an instance of this class given a binary logical expression.
CompoundCriteria(int operator, java.util.List criteria)
          Constructs an instance of this class given a general logical expression.
CompoundCriteria(java.util.List criteria)
          Constructs an instance of this class given the criteria.
 
Method Summary
 void acceptVisitor(LanguageVisitor visitor)
          Method for accepting a visitor.
 void addCriteria(Criteria criteria)
          Add another criteria to the clause.
 java.lang.Object clone()
          Deep clone.
 boolean equals(java.lang.Object obj)
          Override equals() method.
 java.util.List<Criteria> getCriteria()
          Returns the list of criteria.
 Criteria getCriteria(int index)
          Returns the criteria at the specified index.
 int getCriteriaCount()
          Returns the number of criteria in this clause.
 int getOperator()
          Returns the operator used in the logical expression.
 int hashCode()
          Get hash code.
protected  void reset()
          Reset criteria so there are no more.
 void set(int operator, Criteria criteria)
          Sets a "standard" unary criteria.
 void set(int operator, Criteria left, Criteria right)
          Sets a "standard" operand-operator-operand criteria.
 void set(int operator, java.util.List criteria)
          Sets the operator and an arbitrary set of criteria.
 void setCriteria(java.util.List<Criteria> criteria)
          Sets the criteria.
 void setOperator(int operator)
          Sets the operator used in the logical expression.
 
Methods inherited from class com.metamatrix.query.sql.lang.Criteria
combineCriteria, combineCriteria, combineCriteria, separateCriteriaByAnd, toConjunctiveNormalForm, toDisjunctiveNormalForm, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OR

public static final int OR
Constant indicating the logical "or" of two or more criteria.

See Also:
Constant Field Values

AND

public static final int AND
Constant indicating the logical "and" of two or more criteria.

See Also:
Constant Field Values
Constructor Detail

CompoundCriteria

public CompoundCriteria()
Constructs a default instance of this class.


CompoundCriteria

public CompoundCriteria(java.util.List criteria)
Constructs an instance of this class given the criteria. Subclasses are responsible for defining how the criteria are inter-related in a logical expression.

Parameters:
criteria - List of Criteria being added

CompoundCriteria

public CompoundCriteria(int operator,
                        Criteria left,
                        Criteria right)
Constructs an instance of this class given a binary logical expression. The logical expression is constructed in terms of a left criteria clause, an operator (either OR or AND), and a right criteria clause.

Parameters:
left - The criteria left of the operator
right - The criteria right of the operator
operator - The logical operator
See Also:
set(int,Criteria,Criteria)

CompoundCriteria

public CompoundCriteria(int operator,
                        java.util.List criteria)
Constructs an instance of this class given a general logical expression. The logical expression is constructed in terms of an operator (either OR or AND), and a set of criteria clauses.

Parameters:
operator - The logical operator
criteria - The list of Criteria
Method Detail

getOperator

public int getOperator()
Returns the operator used in the logical expression. The returned value can be compared to constants defined in this class.

Returns:
The operator

setOperator

public void setOperator(int operator)
Sets the operator used in the logical expression.

Parameters:
operator - The operator
Throws:
java.lang.IllegalArgumentException - If operator is invalid

getCriteria

public java.util.List<Criteria> getCriteria()
Returns the list of criteria.

Returns:
List of Criteria

setCriteria

public void setCriteria(java.util.List<Criteria> criteria)
Sets the criteria.

Parameters:
criteria - The list of Criteria

getCriteriaCount

public int getCriteriaCount()
Returns the number of criteria in this clause.

Returns:
Criteria

getCriteria

public Criteria getCriteria(int index)
Returns the criteria at the specified index.

Returns:
Criteria
Throws:
java.lang.IllegalArgumentException - if no criteria have been specified

addCriteria

public void addCriteria(Criteria criteria)
Add another criteria to the clause.

Parameters:
criteria - The criteria

reset

protected void reset()
Reset criteria so there are no more. After this call, getCriteriaCount will return 0.


set

public void set(int operator,
                Criteria left,
                Criteria right)
Sets a "standard" operand-operator-operand criteria.

Parameters:
operator - The logical operator
left - The first criteria
right - The second criteria
See Also:
set(int,List)

set

public void set(int operator,
                Criteria criteria)
Sets a "standard" unary criteria.

Parameters:
operator - The unary logical operator
criteria - The criteria
See Also:
set(int,List)

set

public void set(int operator,
                java.util.List criteria)
Sets the operator and an arbitrary set of criteria.

Parameters:
operator - The logical operator
criteria - The set of criteria
See Also:
set(int,Criteria,Criteria)

acceptVisitor

public void acceptVisitor(LanguageVisitor visitor)
Description copied from interface: LanguageObject
Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.

Parameters:
visitor - Visitor being used

hashCode

public int hashCode()
Get hash code. WARNING: The hash code is based on data in the criteria. If data values are changed, the hash code will change - don't hash this object and change values.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Override equals() method.

Overrides:
equals in class java.lang.Object

clone

public java.lang.Object clone()
Deep clone. It returns a new LogicalCriteria with a new list of clones of the criteria objects.

Specified by:
clone in interface LanguageObject
Specified by:
clone in class Criteria
Returns:
Deep clone of this criteria


Copyright © 2009. All Rights Reserved.