Class 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.
    • 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.
        Specified by:
        acceptVisitor in interface LanguageObject
        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 Object
        Returns:
        Hash code
      • equals

        public boolean equals​(Object obj)
        Override equals() method.
        Overrides:
        equals in class Object
        Parameters:
        obj - Other object
        Returns:
        True if equal