Package org.teiid.query.sql.lang
Class CompoundCriteria
- java.lang.Object
-
- org.teiid.query.sql.lang.Criteria
-
- org.teiid.query.sql.lang.LogicalCriteria
-
- org.teiid.query.sql.lang.CompoundCriteria
-
- All Implemented Interfaces:
Cloneable
,LanguageObject
,Expression
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".
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
-
-
Constructor Summary
Constructors Constructor Description CompoundCriteria()
Constructs a default instance of this class.CompoundCriteria(int operator, List criteria)
Constructs an instance of this class given a general logical expression.CompoundCriteria(int operator, Criteria left, Criteria right)
Constructs an instance of this class given a binary logical expression.CompoundCriteria(List<? extends Criteria> criteria)
Constructs an instance of this class given the criteria.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.void
addCriteria(Criteria criteria)
Add another criteria to the clause.Object
clone()
Deep clone.boolean
equals(Object obj)
Override equals() method.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, List criteria)
Sets the operator and an arbitrary set of criteria.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
setCriteria(List<Criteria> criteria)
Sets the criteria.void
setOperator(int operator)
Sets the operator used in the logical expression.-
Methods inherited from class org.teiid.query.sql.lang.Criteria
applyDemorgan, combineCriteria, combineCriteria, combineCriteria, getType, separateCriteriaByAnd, toString
-
-
-
-
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(List<? extends Criteria> 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 ofCriteria
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 operatorright
- The criteria right of the operatoroperator
- The logical operator- See Also:
set(int,Criteria,Criteria)
-
CompoundCriteria
public CompoundCriteria(int operator, 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 operatorcriteria
- The list ofCriteria
-
-
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:
IllegalArgumentException
- If operator is invalid
-
getCriteria
public List<Criteria> getCriteria()
Returns the list of criteria.- Returns:
- List of
Criteria
-
setCriteria
public void setCriteria(List<Criteria> criteria)
Sets the criteria.- Parameters:
criteria
- The list ofCriteria
-
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:
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 operatorleft
- The first criteriaright
- 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 operatorcriteria
- The criteria- See Also:
set(int,List)
-
set
public void set(int operator, List criteria)
Sets the operator and an arbitrary set of criteria.- Parameters:
operator
- The logical operatorcriteria
- 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.
-
equals
public boolean equals(Object obj)
Override equals() method.
-
clone
public Object clone()
Deep clone. It returns a new LogicalCriteria with a new list of clones of the criteria objects.- Specified by:
clone
in interfaceLanguageObject
- Specified by:
clone
in classCriteria
- Returns:
- Deep clone of this criteria
-
-