Class LikeFilter<R>

Type Parameters:
R - the type of resources (e.g. Feature) used as inputs.
All Implemented Interfaces:
Serializable, Predicate<R>, Filter<R>, Optimization.OnFilter<R>

final class LikeFilter<R> extends FilterNode<R> implements Optimization.OnFilter<R>
A character string comparison operator with pattern matching.
Since:
1.1
Version:
1.1
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • expression

      private final Expression<? super R, ?> expression
      The source of values to compare against the pattern.
    • pattern

      private final String pattern
      The pattern to match against expression values. The wildcard, singleChar and escape characters have special meanings.
    • wildcard

      private final char wildcard
      The pattern character for matching any sequence of characters.
      See Also:
    • singleChar

      private final char singleChar
      The pattern character for matching exactly one character.
      See Also:
    • escape

      private final char escape
      The pattern character for indicating that the next character should be matched literally.
      See Also:
    • isMatchingCase

      private final boolean isMatchingCase
      Specifies how a filter expression processor should perform string comparisons.
      See Also:
    • regex

      private final Pattern regex
      The regular expression.
  • Constructor Details

    • LikeFilter

      LikeFilter(Expression<? super R, ?> expression, String pattern, char wildcard, char singleChar, char escape, boolean isMatchingCase)
      Creates a new operator.
      Parameters:
      expression - source of values to compare against the pattern.
      pattern - pattern to match against expression values.
      wildcard - pattern character for matching any sequence of characters.
      singleChar - pattern character for matching exactly one character.
      escape - pattern character for indicating that the next character should be matched literally.
      isMatchingCase - specifies how a filter expression processor should perform string comparisons.
    • LikeFilter

      private LikeFilter(LikeFilter<R> original, Expression<? super R, ?> expression)
      Creates a new filter of the same type but different parameters.
  • Method Details

    • getOperatorType

      public ComparisonOperatorName getOperatorType()
      Description copied from interface: Filter
      Returns the nature of the operator.
      Specified by:
      getOperatorType in interface Filter<R>
      Returns:
      the nature of this operator.
    • recreate

      public Filter<R> recreate(Expression<? super R, ?>[] effective)
      Creates a new filter of the same type but different parameters.
      Specified by:
      recreate in interface Optimization.OnFilter<R>
      Parameters:
      effective - the expressions to use as a replacement of this filter expressions.
      Returns:
      the new filter, or this if unsupported.
    • getChildren

      protected Collection<?> getChildren()
      Returns the children of this node for displaying purposes. This is used by Node.toString(), Node.hashCode() and Node.equals(Object) implementations.
      Specified by:
      getChildren in class Node
      Returns:
      the children of this node, or an empty collection if none.
    • getExpressions

      public List<Expression<? super R, ?>> getExpressions()
      Returns the expression whose values will be compared by this operator, together with the pattern.
      Specified by:
      getExpressions in interface Filter<R>
      Returns:
      the expressions used as inputs, or an empty list if none.
    • getWildCard

      public char getWildCard()
      Returns the pattern character for matching any sequence of characters. For the SQL "LIKE" operator, this property is the % character.
    • getSingleChar

      public char getSingleChar()
      Returns the pattern character for matching exactly one character. For the SQL "LIKE" operator, this property is the _ character.
    • getEscapeChar

      public char getEscapeChar()
      Returns the pattern character for indicating that the next character should be matched literally. For the SQL "LIKE" operator, this property is the ' character.
    • isMatchingCase

      public boolean isMatchingCase()
      Specifies how a filter expression processor should perform string comparisons.
    • test

      public boolean test(R object)
      Returns true if the expression value computed from the given object matches the pattern.
      Specified by:
      test in interface Filter<R>
      Specified by:
      test in interface Predicate<R>
      Parameters:
      object - the object (often a Feature instance) to evaluate.
      Returns:
      true if the test(s) are passed for the provided object.
    • isMetaCharacter

      static boolean isMetaCharacter(char c)
      Returns true if given character is a regular expression meta-character.