com.metamatrix.query.sql.lang
Class MatchCriteria

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

public class MatchCriteria
extends PredicateCriteria

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.

See Also:
Serialized Form

Nested Class Summary
static class MatchCriteria.PatternTranslator
          Utility to convert the pattern into a different match syntax
 
Field Summary
static char MATCH_CHAR
          The default single match character - '_'
static char NULL_ESCAPE_CHAR
          The internal null escape character
static char WILDCARD_CHAR
          The default wildcard character - '%'
 
Constructor Summary
MatchCriteria()
          Constructs a default instance of this class.
MatchCriteria(Expression leftExpression, Expression rightExpression)
          Constructs an instance of this class from a left and right expression
MatchCriteria(Expression leftExpression, Expression rightExpression, char escapeChar)
          Constructs an instance of this class from a left and right expression and an escape character
 
Method Summary
 void acceptVisitor(LanguageVisitor visitor)
          Method for accepting a visitor.
 java.lang.Object clone()
          Deep copy of object
 boolean equals(java.lang.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.
 Expression getRightExpression()
          Get right expression.
 int hashCode()
          Get hash code.
 boolean isNegated()
          Returns whether this criteria is negated.
 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 setNegated(boolean negationFlag)
          Sets the negation flag for this criteria.
 void setRightExpression(Expression expression)
          Set right 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

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 check
rightExpression - 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 check
rightExpression - The match expression
escapeChar - 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

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
Returns:
Hash code

equals

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

Overrides:
equals in class java.lang.Object
Parameters:
obj - Other object
Returns:
True if equal

clone

public java.lang.Object clone()
Deep copy of object

Specified by:
clone in interface LanguageObject
Specified by:
clone in class PredicateCriteria
Returns:
Deep copy of object


Copyright © 2009. All Rights Reserved.