Package org.teiid.query.sql.lang
Class MatchCriteria
- java.lang.Object
-
- org.teiid.query.sql.lang.Criteria
-
- org.teiid.query.sql.lang.PredicateCriteria
-
- org.teiid.query.sql.lang.MatchCriteria
-
- All Implemented Interfaces:
Cloneable
,PredicateCriteria.Negatable
,LanguageObject
,Expression
public class MatchCriteria extends PredicateCriteria implements PredicateCriteria.Negatable
This class represents a criteria involving a string expression to be matched against a string expression match value. The match value may contain a few special characters: % represents 0 or more characters and _ represents a single match character. The escape character can be used to escape an actual % or _ within a match string.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MatchCriteria.PatternTranslator
Utility to convert the pattern into a different match syntax-
Nested classes/interfaces inherited from class org.teiid.query.sql.lang.PredicateCriteria
PredicateCriteria.Negatable
-
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
-
-
Field Summary
Fields Modifier and Type Field Description static char
MATCH_CHAR
The default single match character - '_'static char
NULL_ESCAPE_CHAR
The internal null escape characterstatic char
WILDCARD_CHAR
The default wildcard character - '%'
-
Constructor Summary
Constructors Constructor Description MatchCriteria()
Constructs a default instance of this class.MatchCriteria(Expression leftExpression, Expression rightExpression)
Constructs an instance of this class from a left and right expressionMatchCriteria(Expression leftExpression, Expression rightExpression, char escapeChar)
Constructs an instance of this class from a left and right expression and an escape character
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.Object
clone()
Deep copy of objectboolean
equals(Object obj)
Override equals() method.char
getEscapeChar()
Get the escape character, which can be placed before the wildcard or single match character in the expression to prevent it from being used as a wildcard or single match.Expression
getLeftExpression()
Get left expression.Like.MatchMode
getMode()
static Pattern
getPattern(String newPattern, String originalPattern, int flags)
Expression
getRightExpression()
Get right expression.int
hashCode()
Get hash code.boolean
isNegated()
Returns whether this criteria is negated.void
negate()
void
setEscapeChar(char escapeChar)
Set the escape character which can be used when the wildcard or single character should be used literally.void
setLeftExpression(Expression expression)
Set left expression.void
setMode(Like.MatchMode mode)
void
setNegated(boolean negationFlag)
Sets the negation flag for this criteria.void
setRightExpression(Expression expression)
Set right expression.-
Methods inherited from class org.teiid.query.sql.lang.Criteria
applyDemorgan, combineCriteria, combineCriteria, combineCriteria, getType, separateCriteriaByAnd, toString
-
-
-
-
Field Detail
-
WILDCARD_CHAR
public static final char WILDCARD_CHAR
The default wildcard character - '%'- See Also:
- Constant Field Values
-
MATCH_CHAR
public static final char MATCH_CHAR
The default single match character - '_'- See Also:
- Constant Field Values
-
NULL_ESCAPE_CHAR
public static final char NULL_ESCAPE_CHAR
The internal null escape character- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MatchCriteria
public MatchCriteria()
Constructs a default instance of this class.
-
MatchCriteria
public MatchCriteria(Expression leftExpression, Expression rightExpression)
Constructs an instance of this class from a left and right expression- Parameters:
leftExpression
- The expression to checkrightExpression
- The match expression
-
MatchCriteria
public MatchCriteria(Expression leftExpression, Expression rightExpression, char escapeChar)
Constructs an instance of this class from a left and right expression and an escape character- Parameters:
leftExpression
- The expression to checkrightExpression
- The match expressionescapeChar
- The escape character, to allow literal use of wildcard and single match chars
-
-
Method Detail
-
setLeftExpression
public void setLeftExpression(Expression expression)
Set left expression.- Parameters:
expression
- expression
-
getLeftExpression
public Expression getLeftExpression()
Get left expression.- Returns:
- Left expression
-
setRightExpression
public void setRightExpression(Expression expression)
Set right expression.- Parameters:
expression
- expression
-
getRightExpression
public Expression getRightExpression()
Get right expression.- Returns:
- right expression
-
getEscapeChar
public char getEscapeChar()
Get the escape character, which can be placed before the wildcard or single match character in the expression to prevent it from being used as a wildcard or single match. The escape character must not be used elsewhere in the expression. For example, to match "35%" without activating % as a wildcard, set the escape character to '$' and use the expression "35$%".- Returns:
- Escape character, if not set will return
NULL_ESCAPE_CHAR
-
setEscapeChar
public void setEscapeChar(char escapeChar)
Set the escape character which can be used when the wildcard or single character should be used literally.- Parameters:
escapeChar
- New escape character
-
isNegated
public boolean isNegated()
Returns whether this criteria is negated.- Returns:
- flag indicating whether this criteria contains a NOT
-
setNegated
public void setNegated(boolean negationFlag)
Sets the negation flag for this criteria.- Parameters:
negationFlag
- true if this criteria contains a NOT; false otherwise
-
negate
public void negate()
- Specified by:
negate
in interfacePredicateCriteria.Negatable
-
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.- Specified by:
acceptVisitor
in interfaceLanguageObject
- 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 copy of object- Specified by:
clone
in interfaceLanguageObject
- Specified by:
clone
in classPredicateCriteria
- Returns:
- Deep copy of object
-
getPattern
public static Pattern getPattern(String newPattern, String originalPattern, int flags) throws ExpressionEvaluationException
- Throws:
ExpressionEvaluationException
-
getMode
public Like.MatchMode getMode()
-
setMode
public void setMode(Like.MatchMode mode)
-
-