private static PropertyIsLike parsePropertyIsLikeOperator( XMLStreamReader xmlStream ) throws XMLStreamException { // this is a deegree extension over Filter 1.1.0 spec. boolean matchCase = getAttributeValueAsBoolean( xmlStream, null, "matchCase", true ); String wildCard = getRequiredAttributeValue( xmlStream, "wildCard" ); String singleChar = getRequiredAttributeValue( xmlStream, "singleChar" ); String escapeChar = getRequiredAttributeValue( xmlStream, "escapeChar" ); nextElement( xmlStream ); ValueReference propName = parsePropertyName( xmlStream, false ); nextElement( xmlStream ); if ( !"Literal".equals( xmlStream.getLocalName() ) ) { String message = "FilterEncoding 1.1.0 does not allow other than Literal elements as second expression in PropertyIsLike filters!"; throw new XMLStreamException( message ); } Literal<?> literal = parseLiteral( xmlStream ); nextElement( xmlStream ); return new PropertyIsLike( propName, literal, wildCard, singleChar, escapeChar, matchCase, null ); }
private PropertyIsLike buildIsLike( Expression propName, Expression literal, boolean matchCase ) throws UnmappableException { if ( !( propName instanceof ValueReference ) || !( literal instanceof Literal ) ) { String msg = "Can not map filter. Multi-valued columns can only be compared to literals."; throw new UnmappableException( msg ); } String wildCard = "*"; String singleChar = "?"; String escapeChar = "\\"; String s = ( (Literal<?>) literal ).getValue().toString(); s = StringUtils.replaceAll( s, escapeChar, escapeChar + escapeChar ); s = StringUtils.replaceAll( s, singleChar, escapeChar + singleChar ); s = StringUtils.replaceAll( s, wildCard, escapeChar + wildCard ); Literal<PrimitiveValue> escapedLiteral = new Literal<PrimitiveValue>( new PrimitiveValue( s ), null ); return new PropertyIsLike( (ValueReference) propName, escapedLiteral, wildCard, singleChar, escapeChar, matchCase, null ); }
private static PropertyIsLike parsePropertyIsLikeOperator( XMLStreamReader xmlStream ) throws XMLStreamException { // this is a deegree extension over Filter 1.0.0 boolean matchCase = getAttributeValueAsBoolean( xmlStream, null, "matchCase", true ); String wildCard = getRequiredAttributeValue( xmlStream, "wildCard" ); String singleChar = getRequiredAttributeValue( xmlStream, "singleChar" ); String escapeChar = getRequiredAttributeValue( xmlStream, "escape" ); nextElement( xmlStream ); ValueReference propName = parsePropertyName( xmlStream ); nextElement( xmlStream ); Literal<?> literal = parseLiteral( xmlStream ); nextElement( xmlStream ); return new PropertyIsLike( propName, literal, wildCard, singleChar, escapeChar, matchCase, null ); }
private static PropertyIsLike parsePropertyIsLikeOperator( XMLStreamReader xmlStream ) throws XMLStreamException { // this is a deegree extension over Filter 2.0.0 spec. (TODO should this be null, if not present?) Boolean matchCase = getAttributeValueAsBoolean( xmlStream, null, "matchCase", true ); // this is a deegree extension over Filter 2.0.0 spec. (TODO should this be null, if not present?) MatchAction matchAction = null; String s = XMLStreamUtils.getAttributeValue( xmlStream, "matchAction" ); if ( s != null ) { matchAction = parseMatchAction( xmlStream, s ); } String wildCard = getRequiredAttributeValue( xmlStream, "wildCard" ); String singleChar = getRequiredAttributeValue( xmlStream, "singleChar" ); String escapeChar = getRequiredAttributeValue( xmlStream, "escapeChar" ); nextElement( xmlStream ); Expression value = parseExpression( xmlStream ); nextElement( xmlStream ); Expression pattern = parseExpression( xmlStream ); nextElement( xmlStream ); return new PropertyIsLike( value, pattern, wildCard, singleChar, escapeChar, matchCase, matchAction ); }
case PROPERTY_IS_LIKE: PropertyIsLike pil = (PropertyIsLike) o; return new PropertyIsLike( exs[0], exs[1], pil.getWildCard(), pil.getSingleChar(), pil.getEscapeChar(), o.isMatchCase(), o.getMatchAction() ); case PROPERTY_IS_NIL:
case PROPERTY_IS_LIKE: PropertyIsLike pil = (PropertyIsLike) op; return new PropertyIsLike( copy( pil.getExpression() ), copyExpression( pil.getPattern(), values ), pil.getWildCard(), pil.getSingleChar(), pil.getEscapeChar(), pil.isMatchCase(), pil.getMatchAction() );