/** * see convertToSQL92 * * @throws IllegalArgumentException */ public String getSQL92LikePattern() throws IllegalArgumentException { if (escape.length() != 1) { throw new IllegalArgumentException( "Like Pattern --> escape char should be of length exactly 1"); } if (wildcardSingle.length() != 1) { throw new IllegalArgumentException( "Like Pattern --> wildcardSingle char should be of length exactly 1"); } if (wildcardMulti.length() != 1) { throw new IllegalArgumentException( "Like Pattern --> wildcardMulti char should be of length exactly 1"); } return LikeFilterImpl.convertToSQL92( escape.charAt(0), wildcardMulti.charAt(0), wildcardSingle.charAt(0), matchingCase, pattern); }
public PropertyIsLike like( Expression expr, String pattern, String wildcard, String singleChar, String escape, boolean matchCase, MatchAction matchAction) { LikeFilterImpl filter = new LikeFilterImpl(matchAction); filter.setExpression(expr); filter.setPattern(pattern, wildcard, singleChar, escape); filter.setMatchingCase(matchCase); return filter; }
/** * 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. & * * @param obj - the object to compare this LikeFilter against. * @return true if specified object is equal to this filter; false otherwise. */ public boolean equals(Object obj) { if (obj instanceof LikeFilterImpl) { LikeFilterImpl lFilter = (LikeFilterImpl) obj; // REVISIT: check for nulls. return ((Filters.getFilterType(lFilter) == Filters.getFilterType(this)) && lFilter.getExpression().equals(this.attribute) && lFilter.getPattern().equals(this.pattern)); } return false; }
public LikeFilterImpl( org.opengis.filter.expression.Expression expr, String pattern, String wildcardMulti, String wildcardSingle, String escape, MatchAction matchAction) { this(matchAction); setExpression(expr); setLiteral(pattern); setWildCard(wildcardMulti); setSingleChar(wildcardSingle); setEscape(escape); }
public void testLikeFilter() throws IllegalFilterException { LikeFilterImpl lFilter1 = new LikeFilterImpl(); LikeFilterImpl lFilter2 = new LikeFilterImpl(); String pattern = "te_st!"; String wcMulti = "!"; String wcSingle = "_"; String escape = "#"; testExp2 = new LiteralExpressionImpl(Integer.valueOf(45)); testExp3 = new AttributeExpressionImpl(testSchema, "testInteger"); testExp4 = new AttributeExpressionImpl(testSchema, "testInteger"); lFilter1.setExpression(testExp3); lFilter2.setExpression(testExp4); lFilter1.setPattern(pattern, wcMulti, wcSingle, escape); lFilter2.setPattern(pattern, wcMulti, wcSingle, escape); assertTrue(lFilter1.equals(lFilter2)); lFilter2.setPattern("te__t!", wcMulti, wcSingle, escape); assertTrue(!lFilter1.equals(lFilter2)); lFilter2.setPattern(pattern, wcMulti, wcSingle, escape); lFilter2.setExpression(testExp2); assertTrue(!lFilter1.equals(lFilter2)); }
public PropertyIsLike like(Expression expr, String pattern, String wildcard, String singleChar, String escape) { LikeFilterImpl filter = new LikeFilterImpl(); filter.setExpression(expr); filter.setPattern(pattern,wildcard,singleChar,escape); return filter; }
char multi = filter.getWildcardMulti().charAt(0); char single = filter.getWildcardSingle().charAt(0); boolean matchCase = ((LikeFilterImpl)filter).isMatchingCase(); String pattern = LikeFilterImpl.convertToSQL92(esc, multi, single, matchCase, filter.getPattern());
/** * 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. & * * @param obj - the object to compare this LikeFilter against. * * @return true if specified object is equal to this filter; false * otherwise. */ public boolean equals(Object obj) { if (obj instanceof LikeFilterImpl) { LikeFilterImpl lFilter = (LikeFilterImpl) obj; //REVISIT: check for nulls. return ((lFilter.getFilterType() == this.filterType) && lFilter.getValue().equals(this.attribute) && lFilter.getPattern().equals(this.pattern)); } return false; }
((LikeFilterImpl) curFilter).setExpression(expression); curState = "pattern"; } else if (curState.equals("pattern")) { ((LikeFilterImpl) curFilter).setMatchingCase(Boolean.parseBoolean(matchCase)); .setPattern(expression, wildcard, singleChar, escapeChar); curState = "complete"; } else {
AttributeExpressionImpl impl = (AttributeExpressionImpl) likeFilter.getExpression(); String attribute = impl.getPropertyName(); String value = likeFilter.getLiteral(); if ("location".equalsIgnoreCase(attribute)) {
/** * Accessor method to retrieve the pattern. * * @return the pattern being matched. * @deprecated use {@link #getLiteral()} */ public final String getPattern() { return getLiteral(); }
/** * Sets the expression to be evalutated as being like the pattern * * @param attribute The value of the attribute for comparison. * @throws IllegalFilterException Filter is illegal. * @deprecated Use {@link #setExpression(org.opengis.filter.expression.Expression)} */ public final void setValue(Expression attribute) throws IllegalFilterException { setExpression(attribute); }
/** * Sets the match pattern for this FilterLike. * * @param p the expression which evaluates to the match pattern for this filter * @param wildcardMulti the string that represents a mulitple character (1->n) wildcard * @param wildcardSingle the string that represents a single character (1) wildcard * @param escape the string that represents an escape character * @deprecated use one of {@link PropertyIsLike#setExpression(Expression)} {@link * PropertyIsLike#setWildCard(String)} {@link PropertyIsLike#setSingleChar(String)} {@link * PropertyIsLike#setEscape(String)} */ public final void setPattern( org.opengis.filter.expression.Expression p, String wildcardMulti, String wildcardSingle, String escape) { if (p instanceof Literal) { Literal literal = (Literal) p; Object value = literal.getValue(); if (value != null && value instanceof String) { String pattern = (String) value; setPattern(pattern, wildcardMulti, wildcardSingle, escape); } else { throw new ClassCastException("Pattern Literal must be a string:" + value); } } else { throw new ClassCastException("Pattern must be a literal String"); } }
/** * Creates a Like Filter. * * @return The new Like Filter. */ public LikeFilter createLikeFilter() { return new LikeFilterImpl(); }
public LikeFilterImpl( org.opengis.filter.expression.Expression expr, String pattern, String wildcardMulti, String wildcardSingle, String escape) { this(); setExpression(expr); setLiteral(pattern); setWildCard(wildcardMulti); setSingleChar(wildcardSingle); setEscape(escape); }
/** * 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. & * * @param obj - the object to compare this LikeFilter against. * * @return true if specified object is equal to this filter; false * otherwise. */ public boolean equals(Object obj) { if (obj instanceof LikeFilterImpl) { LikeFilterImpl lFilter = (LikeFilterImpl) obj; //REVISIT: check for nulls. return ((lFilter.getFilterType() == this.filterType) && lFilter.getValue().equals(this.attribute) && lFilter.getPattern().equals(this.pattern)); } return false; }
/** * Accessor method to retrieve the pattern. * * @return the pattern being matched. * * @deprecated use {@link #getLiteral()} */ public final String getPattern() { return getLiteral(); }
/** * Sets the expression to be evalutated as being like the pattern * * @param attribute The value of the attribute for comparison. * * @throws IllegalFilterException Filter is illegal. */ public final void setValue(Expression attribute) throws IllegalFilterException { setExpression(attribute); }
/** * Sets the match pattern for this FilterLike. * * @param p the expression which evaluates to the match pattern for this * filter * @param wildcardMulti the string that represents a mulitple character * (1->n) wildcard * @param wildcardSingle the string that represents a single character (1) * wildcard * @param escape the string that represents an escape character * * @deprecated use one of * {@link PropertyIsLike#setExpression(Expression)} * {@link PropertyIsLike#setWildCard(String)} * {@link PropertyIsLike#setSingleChar(String)} * {@link PropertyIsLike#setEscape(String)} */ public final void setPattern(org.geotools.filter.Expression p, String wildcardMulti, String wildcardSingle, String escape) { setPattern(p.toString(), wildcardMulti, wildcardSingle, escape); }
/** * Creates a Like Filter. * * @return The new Like Filter. */ public LikeFilter createLikeFilter() { return new LikeFilterImpl(); }