private static String retrieveMatchActionAsString( ComparisonOperator operator, XMLStreamWriter writer ) throws XMLStreamException { MatchAction matchAction = operator.getMatchAction(); if ( matchAction != null ) { switch ( matchAction ) { case ALL: return "All"; case ANY: return "Any"; case ONE: return "One"; default: return null; } } return null; } }
private static ComparisonOperator repair( ComparisonOperator o, Map<String, QName> bindings, Set<QName> validNames ) { Expression[] exs = o.getParams(); for ( int i = 0; i < exs.length; ++i ) { exs[i] = repair( exs[i], bindings, validNames ); switch ( o.getSubType() ) { case PROPERTY_IS_BETWEEN: return new PropertyIsBetween( exs[1], exs[0], exs[2], o.isMatchCase(), o.getMatchAction() ); case PROPERTY_IS_EQUAL_TO: return new PropertyIsEqualTo( exs[0], exs[1], o.isMatchCase(), o.getMatchAction() ); case PROPERTY_IS_GREATER_THAN: return new PropertyIsGreaterThan( exs[0], exs[1], o.isMatchCase(), o.getMatchAction() ); case PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO: return new PropertyIsGreaterThanOrEqualTo( exs[0], exs[1], o.isMatchCase(), o.getMatchAction() ); case PROPERTY_IS_LESS_THAN: return new PropertyIsLessThan( exs[0], exs[1], o.isMatchCase(), o.getMatchAction() ); case PROPERTY_IS_LESS_THAN_OR_EQUAL_TO: return new PropertyIsLessThanOrEqualTo( exs[0], exs[1], o.isMatchCase(), o.getMatchAction() ); 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: PropertyIsNil pin = (PropertyIsNil) o; return new PropertyIsNil( exs[0], pin.getNilReason(), o.getMatchAction() ); case PROPERTY_IS_NOT_EQUAL_TO: return new PropertyIsNotEqualTo( exs[0], exs[1], o.isMatchCase(), o.getMatchAction() ); case PROPERTY_IS_NULL: return new PropertyIsNull( exs[0], o.getMatchAction() );
/** * Creates a pair of {@link PrimitiveValue} instances from the given {@link TypedObjectNode}s. * * @param node1 * first node, can be <code>null</code> * @param node2 * second node, can be <code>null</code> * @return pair of primitive values, never <code>null</code> (and values not null) * @throws FilterEvaluationException */ protected Pair<PrimitiveValue, PrimitiveValue> getPrimitiveValues( TypedObjectNode node1, TypedObjectNode node2 ) throws FilterEvaluationException { PrimitiveValue primitive1 = getPrimitiveValue( node1 ); PrimitiveValue primitive2 = getPrimitiveValue( node2 ); return new Pair<PrimitiveValue, PrimitiveValue>( primitive1, primitive2 ); }
comparisonOperator = new PropertyIsEqualTo( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_NOT_EQUAL_TO: comparisonOperator = new PropertyIsNotEqualTo( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_LESS_THAN: comparisonOperator = new PropertyIsLessThan( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_LESS_THAN_OR_EQUAL_TO: comparisonOperator = new PropertyIsLessThanOrEqualTo( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_GREATER_THAN: comparisonOperator = new PropertyIsGreaterThan( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO: comparisonOperator = new PropertyIsGreaterThanOrEqualTo( parameter1, parameter2, matchCase, null ); break; default:
private static void export( PropertyIsLike operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsLike" ); writer.writeAttribute( "wildCard", operator.getWildCard() ); writer.writeAttribute( "singleChar", operator.getSingleChar() ); writer.writeAttribute( "escapeChar", operator.getEscapeChar() ); export( operator.getExpression(), writer ); export( operator.getPattern(), writer ); writer.writeEndElement(); }
private static void export( PropertyIsBetween operator, XMLStreamWriter writer ) throws XMLStreamException, UnknownCRSException, TransformationException { writer.writeStartElement( FES_20_NS, "PropertyIsBetween" ); export( operator.getExpression(), writer ); writer.writeStartElement( FES_20_NS, "LowerBoundary" ); export( operator.getLowerBoundary(), writer ); writer.writeEndElement(); writer.writeStartElement( FES_20_NS, "UpperBoundary" ); export( operator.getUpperBoundary(), writer ); writer.writeEndElement(); writer.writeEndElement(); }
private static void export( PropertyIsEqualTo operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsEqualTo" ); String matchAction = retrieveMatchActionAsString( operator, writer ); if ( matchAction != null ) writer.writeAttribute( "matchAction", matchAction ); writer.writeAttribute( "matchCase", Boolean.toString( operator.isMatchCase() ) ); export( operator.getParameter1(), writer ); export( operator.getParameter2(), writer ); writer.writeEndElement(); }
private static void export( PropertyIsNotEqualTo operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsNotEqualTo" ); String matchAction = retrieveMatchActionAsString( operator, writer ); if ( matchAction != null ) writer.writeAttribute( "matchAction", matchAction ); writer.writeAttribute( "matchCase", Boolean.toString( operator.isMatchCase() ) ); export( operator.getParameter1(), writer ); export( operator.getParameter2(), writer ); writer.writeEndElement(); }
private static void export( PropertyIsGreaterThanOrEqualTo operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsGreaterThanOrEqualTo" ); String matchAction = retrieveMatchActionAsString( operator, writer ); if ( matchAction != null ) writer.writeAttribute( "matchAction", matchAction ); writer.writeAttribute( "matchCase", Boolean.toString( operator.isMatchCase() ) ); export( operator.getParameter1(), writer ); export( operator.getParameter2(), writer ); writer.writeEndElement(); }
private static void export( PropertyIsGreaterThan operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsGreaterThan" ); String matchAction = retrieveMatchActionAsString( operator, writer ); if ( matchAction != null ) writer.writeAttribute( "matchAction", matchAction ); writer.writeAttribute( "matchCase", Boolean.toString( operator.isMatchCase() ) ); export( operator.getParameter1(), writer ); export( operator.getParameter2(), writer ); writer.writeEndElement(); }
private SQLOperation getOperationFromBuilder( PropertyIsLike op, SQLExpression propName, String sqlEncoded ) { SQLOperationBuilder builder = new SQLOperationBuilder(); if ( !op.isMatchCase() ) { builder.add( "LOWER(" ); } builder.add( propName ); if ( op.isMatchCase() ) { builder.add( "::TEXT LIKE '" ); } else { builder.add( "::TEXT) LIKE '" ); } builder.add( sqlEncoded ); builder.add( "'" ); return builder.toOperation(); }
private static void export( PropertyIsNull operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsNull" ); export( operator.getPropertyName(), writer ); writer.writeEndElement(); }
private static PropertyIsNull parsePropertyIsNullOperator( XMLStreamReader xmlStream ) throws XMLStreamException { nextElement( xmlStream ); ValueReference propName = parsePropertyName( xmlStream ); nextElement( xmlStream ); return new PropertyIsNull( propName, 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 void export( PropertyIsNil operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsNil" ); export( operator.getPropertyName(), writer ); writer.writeEndElement(); }
private static PropertyIsNil parsePropertyIsNilOperator( XMLStreamReader xmlStream ) throws XMLStreamException { // 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 nilReason = XMLStreamUtils.getAttributeValue( xmlStream, "nilReason" ); nextElement( xmlStream ); Expression param = parseExpression( xmlStream ); nextElement( xmlStream ); return new PropertyIsNil( param, nilReason, matchAction ); }
comparisonOperator = new PropertyIsEqualTo( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_NOT_EQUAL_TO: comparisonOperator = new PropertyIsNotEqualTo( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_LESS_THAN: comparisonOperator = new PropertyIsLessThan( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_LESS_THAN_OR_EQUAL_TO: comparisonOperator = new PropertyIsLessThanOrEqualTo( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_GREATER_THAN: comparisonOperator = new PropertyIsGreaterThan( parameter1, parameter2, matchCase, null ); break; case PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO: comparisonOperator = new PropertyIsGreaterThanOrEqualTo( parameter1, parameter2, matchCase, null ); break; default:
private static PropertyIsNull parsePropertyIsNullOperator( XMLStreamReader xmlStream ) throws XMLStreamException { nextElement( xmlStream ); ValueReference propName = parsePropertyName( xmlStream, false ); nextElement( xmlStream ); return new PropertyIsNull( propName, null ); }
comparisonOperator = new PropertyIsEqualTo( parameter1, parameter2, matchCase, matchAction ); break; case PROPERTY_IS_NOT_EQUAL_TO: comparisonOperator = new PropertyIsNotEqualTo( parameter1, parameter2, matchCase, matchAction ); break; case PROPERTY_IS_LESS_THAN: comparisonOperator = new PropertyIsLessThan( parameter1, parameter2, matchCase, matchAction ); break; case PROPERTY_IS_LESS_THAN_OR_EQUAL_TO: comparisonOperator = new PropertyIsLessThanOrEqualTo( parameter1, parameter2, matchCase, matchAction ); break; case PROPERTY_IS_GREATER_THAN: comparisonOperator = new PropertyIsGreaterThan( parameter1, parameter2, matchCase, matchAction ); break; case PROPERTY_IS_GREATER_THAN_OR_EQUAL_TO: comparisonOperator = new PropertyIsGreaterThanOrEqualTo( parameter1, parameter2, matchCase, matchAction ); break; default:
private static PropertyIsNull parsePropertyIsNullOperator( XMLStreamReader xmlStream ) throws XMLStreamException { // 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 ); } nextElement( xmlStream ); Expression value = parseExpression( xmlStream ); nextElement( xmlStream ); return new PropertyIsNull( value, matchAction ); }