Class LikeFilterImpl
- All Implemented Interfaces:
Filter
,MultiValuedFilter
,PropertyIsLike
,FilterType
- Author:
- Rob Hranac, Vision for New York
-
Nested Class Summary
Nested classes/interfaces inherited from interface MultiValuedFilter
MultiValuedFilter.MatchAction
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MultiValuedFilter.MatchAction
Used to indicate action with multiple values *Fields inherited from class AbstractFilter
LOGGER
Fields inherited from interface FilterType
ALL, BETWEEN, COMPARE_EQUALS, COMPARE_GREATER_THAN, COMPARE_GREATER_THAN_EQUAL, COMPARE_LESS_THAN, COMPARE_LESS_THAN_EQUAL, COMPARE_NOT_EQUALS, FID, GEOMETRY_BBOX, GEOMETRY_BEYOND, GEOMETRY_CONTAINS, GEOMETRY_CROSSES, GEOMETRY_DISJOINT, GEOMETRY_DWITHIN, GEOMETRY_EQUALS, GEOMETRY_INTERSECTS, GEOMETRY_OVERLAPS, GEOMETRY_TOUCHES, GEOMETRY_WITHIN, LIKE, LOGIC_AND, LOGIC_NOT, LOGIC_OR, NONE, NULL
Fields inherited from interface PropertyIsLike
NAME
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor which flags the operator as like.LikeFilterImpl
(Expression expr, String pattern, String wildcardMulti, String wildcardSingle, String escape) LikeFilterImpl
(Expression expr, String pattern, String wildcardMulti, String wildcardSingle, String escape, MultiValuedFilter.MatchAction matchAction) protected
LikeFilterImpl
(MultiValuedFilter.MatchAction matchAction) -
Method Summary
Modifier and TypeMethodDescriptionaccept
(FilterVisitor visitor, Object extraData) Used by FilterVisitors to perform some action on this filter instance.static String
convertToSQL92
(char escape, char multi, char single, boolean matchCase, String pattern) Deprecated.static String
convertToSQL92
(char escape, char multi, char single, boolean matchCase, String pattern, boolean escapeSingleQuote) Given OGC PropertyIsLike Filter information, construct an SQL-compatible 'like' pattern.boolean
Compares this filter to the specified object.boolean
Determines whether or not a given feature matches this pattern.Getter for property escape.Gets the expression for hte filter.Returns the pattern.* Flag Controlling MatchAction property When one or more of the operands evaluates to multiple values rather than a single value, which action should be taken?Getter for property wildcardSingle.Deprecated.Getter for property wildcardMultiint
hashCode()
Override of hashCode method.boolean
Flag controlling wither comparisons are case sensitive.void
void
void
setLiteral
(String literal) Sets the pattern.void
setMatchCase
(boolean matchingCase) void
setMatchingCase
(boolean matchingCase) void
setSingleChar
(String singleChar) void
setWildCard
(String wildCard) toString()
Return this filter as a string.Methods inherited from class AbstractFilter
isCompareFilter, isGeometryDistanceFilter, isGeometryFilter, isLogicFilter, isMathFilter, isSimpleFilter
Methods inherited from class FilterAbstract
accepts, eval, eval
-
Field Details
-
matchAction
Used to indicate action with multiple values *
-
-
Constructor Details
-
LikeFilterImpl
protected LikeFilterImpl()Constructor which flags the operator as like. -
LikeFilterImpl
public LikeFilterImpl(Expression expr, String pattern, String wildcardMulti, String wildcardSingle, String escape) -
LikeFilterImpl
-
LikeFilterImpl
public LikeFilterImpl(Expression expr, String pattern, String wildcardMulti, String wildcardSingle, String escape, MultiValuedFilter.MatchAction matchAction)
-
-
Method Details
-
convertToSQL92
@Deprecated public static String convertToSQL92(char escape, char multi, char single, boolean matchCase, String pattern) throws IllegalArgumentException Deprecated.Given OGC PropertyIsLike Filter information, construct an SQL-compatible 'like' pattern.SQL % --> match any number of characters _ --> match a single character
NOTE; the SQL command is 'string LIKE pattern [ESCAPE escape-character]' We could re-define the escape character, but I'm not doing to do that in this code since some databases will not handle this case.
Method: 1.
Examples: ( escape ='!', multi='*', single='.' ) broadway* -> 'broadway%' broad_ay -> 'broad_ay' broadway -> 'broadway'
broadway!* -> 'broadway*' (* has no significance and is escaped) can't -> 'can''t' ( ' escaped for SQL compliance)
NOTE: we also handle "'" characters as special because they are end-of-string characters. SQL will convert ' to '' (double single quote).
NOTE: we dont handle "'" as a 'special' character because it would be too confusing to have a special char as another special char. Using this will throw an error (IllegalArgumentException).
- Throws:
IllegalArgumentException
-
convertToSQL92
public static String convertToSQL92(char escape, char multi, char single, boolean matchCase, String pattern, boolean escapeSingleQuote) Given OGC PropertyIsLike Filter information, construct an SQL-compatible 'like' pattern.SQL % --> match any number of characters _ --> match a single character
NOTE; the SQL command is 'string LIKE pattern [ESCAPE escape-character]' We could re-define the escape character, but I'm not doing to do that in this code since some databases will not handle this case.
Method: 1.
Examples: ( escape ='!', multi='*', single='.' ) broadway* -> 'broadway%' broad_ay -> 'broad_ay' broadway -> 'broadway'
broadway!* -> 'broadway*' (* has no significance and is escaped) can't -> 'can''t' ( ' escaped for SQL compliance)
NOTE: when the escapeSingleQuote parameter is false, this method will not convert ' to '' (double single quote) and it is the caller's responsibility to ensure that the resulting pattern is used safely in SQL queries.
NOTE: we dont handle "'" as a 'special' character because it would be too confusing to have a special char as another special char. Using this will throw an error (IllegalArgumentException).
-
getSQL92LikePattern
Deprecated.see convertToSQL92- Throws:
IllegalArgumentException
-
setWildCard
-
setSingleChar
-
setEscape
-
setMatchCase
public void setMatchCase(boolean matchingCase) -
isMatchingCase
public boolean isMatchingCase()Description copied from interface:PropertyIsLike
Flag controlling wither comparisons are case sensitive.The ability to match case is pending the Filter 2.0 specification.
- Specified by:
isMatchingCase
in interfacePropertyIsLike
- Returns:
true
if the comparison is case sensetive, otherwisefalse
.
-
getMatchAction
Description copied from interface:MultiValuedFilter
* Flag Controlling MatchAction property When one or more of the operands evaluates to multiple values rather than a single value, which action should be taken? If there are n values for the left operand and m values for the right operand, there are n * m possible combinations that can be compared,ANY - if any of the possible combinations match, the result is true (aggregated OR) ALL - only if all of the possible combinations match, the result is true (aggregated AND) ONE - only if exactly one of the possible combinations match, the result is true (aggregated XOR)
- Specified by:
getMatchAction
in interfaceMultiValuedFilter
- Returns:
- MatchAction flag
-
setMatchingCase
public void setMatchingCase(boolean matchingCase) -
getExpression
Gets the expression for hte filter.This method calls th deprecated
#getValue()
for backwards compatability with subclasses.- Specified by:
getExpression
in interfacePropertyIsLike
-
setExpression
-
getLiteral
Returns the pattern.- Specified by:
getLiteral
in interfacePropertyIsLike
-
setLiteral
Sets the pattern. -
evaluate
Determines whether or not a given feature matches this pattern. -
toString
Return this filter as a string. -
getEscape
Getter for property escape.- Specified by:
getEscape
in interfacePropertyIsLike
- Returns:
- Value of property escape.
-
getWildCard
Getter for property wildcardMulti- Specified by:
getWildCard
in interfacePropertyIsLike
-
getSingleChar
Getter for property wildcardSingle.- Specified by:
getSingleChar
in interfacePropertyIsLike
-
equals
Compares this filter to the specified object. Returns true if the passed in object is the same as this filter. Checks to make sure the filter types, the value, and the pattern are the same. & -
hashCode
public int hashCode()Override of hashCode method. -
accept
Used by FilterVisitors to perform some action on this filter instance. Typicaly used by Filter decoders, but may also be used by any thing which needs infomration from filter structure. Implementations should always call: visitor.visit(this); It is importatant that this is not left to a parent class unless the parents API is identical.
-