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 ); }
if ( op.getMatchAction() != null && op.getMatchAction() != MatchAction.ANY ) { LOG.warn( "Mapping of operators with matchAction=" + op.getMatchAction() + " to SQL is not implemented (and probably not possible)." ); switch ( op.getSubType() ) { case PROPERTY_IS_BETWEEN: { PropertyIsBetween propIsBetween = (PropertyIsBetween) op; inferType( lower, expr, upper ); builder.add( "(" ); addExpression( builder, lower, op.isMatchCase() ); builder.add( " <= " ); addExpression( builder, expr, op.isMatchCase() ); builder.add( " AND " ); addExpression( builder, expr, op.isMatchCase() ); builder.add( " <= " ); addExpression( builder, upper, op.isMatchCase() ); builder.add( ")" ); sqlOper = builder.toOperation(); inferType( param1, param2 ); SQLOperationBuilder builder = new SQLOperationBuilder( BOOLEAN ); addExpression( builder, param1, op.isMatchCase() ); builder.add( " = " ); addExpression( builder, param2, op.isMatchCase() ); sqlOper = builder.toOperation(); } else { SQLExpression param2 = toProtoSQL( propIsGT.getParameter2(), true );
private static void export( ComparisonOperator operator, XMLStreamWriter writer ) throws XMLStreamException, UnknownCRSException, TransformationException { SubType operatorSubType = operator.getSubType(); switch ( operatorSubType ) { case PROPERTY_IS_BETWEEN: break; default: throw new IllegalArgumentException( "Encoding of operator subtype " + operator.getType() + " is not supported yet!" );
throws XMLStreamException { QName elementName = comparisonOperatorTypeToElementName.get( operator.getSubType() ); writer.writeStartElement( elementName.getNamespaceURI(), elementName.getLocalPart() ); switch ( operator.getSubType() ) { case PROPERTY_IS_BETWEEN: PropertyIsBetween isBetween = (PropertyIsBetween) operator;
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; } }
/** * Performs a checked cast to {@link Comparable}. If the given value is neither null nor a {@link Comparable} * instance, a corresponding {@link FilterEvaluationException} is thrown. * * @param value * @return the very same value (if it is a {@link Comparable} or <code>null</code>) * @throws FilterEvaluationException * if the value is neither <code>null</code> nor a {@link Comparable} */ protected Comparable<?> checkComparableOrNull( Object value ) throws FilterEvaluationException { if ( value != null && !( value instanceof Comparable<?> ) ) { String msg = Messages.getMessage( "FILTER_EVALUATION_NOT_COMPARABLE", this.getType().name(), value ); throw new FilterEvaluationException( msg ); } return (Comparable<?>) value; }
private static void addPropertyNames( Operator operator, List<ValueReference> propNames ) { Operator.Type type = operator.getType(); switch ( type ) { case COMPARISON: ComparisonOperator compOper = (ComparisonOperator) operator; for ( Expression expr : compOper.getParams() ) { addPropertyNames( expr, propNames ); } break; case LOGICAL: LogicalOperator logicalOper = (LogicalOperator) operator; for ( Operator param : logicalOper.getParams() ) { addPropertyNames( param, propNames ); } break; case SPATIAL: SpatialOperator spatialOper = (SpatialOperator) operator; for ( Object param : spatialOper.getParams() ) { if ( param instanceof Expression ) { addPropertyNames( (Expression) param, propNames ); } } break; } }
private Operator copy( Operator op, Map<String, String> values ) { switch ( op.getType() ) { case COMPARISON: switch ( ( (ComparisonOperator) op ).getSubType() ) { case PROPERTY_IS_BETWEEN: PropertyIsBetween piw = (PropertyIsBetween) op;
private PrimitiveValue getPrimitiveValue( TypedObjectNode node ) { if ( node == null ) { return new PrimitiveValue( "null" ); } if ( node instanceof PrimitiveValue ) { return (PrimitiveValue) node; } if ( node instanceof Property ) { return getPrimitiveValue( ( (Property) node ).getValue() ); } if ( node instanceof ElementNode ) { ElementNode elNode = (ElementNode) node; List<TypedObjectNode> children = elNode.getChildren(); if ( children == null || children.isEmpty() ) { return new PrimitiveValue( "null" ); } return getPrimitiveValue( children.get( 0 ) ); } return new PrimitiveValue( node.toString() ); }