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(); }
/** * Translates the given {@link PropertyIsLike} into an {@link SQLOperation}. * <p> * NOTE: This method appends the generated argument inline, i.e. not using a <code>?</code>. This is because of a * problem that has been observed with PostgreSQL 8.0; the execution of the inline version is *much* faster. * </p> * * @param op * comparison operator to be translated, must not be <code>null</code> * @return corresponding SQL expression, never <code>null</code> * @throws UnmappableException * if translation is not possible (usually due to unmappable property names) * @throws FilterEvaluationException * if the expression contains invalid {@link ValueReference}s */ @Override protected SQLOperation toProtoSQL( PropertyIsLike op ) throws UnmappableException, FilterEvaluationException { Expression pattern = op.getPattern(); if ( pattern instanceof Literal ) { String literal = ( (Literal<?>) pattern ).getValue().toString(); return toProtoSql( op, literal ); } else if ( pattern instanceof Function ) { String valueAsString = getStringValueFromFunction( pattern ); return toProtoSql( op, valueAsString ); } String msg = "Mapping of PropertyIsLike with non-literal or non-function comparisons to SQL is not implemented yet."; throw new UnsupportedOperationException( msg ); }
throws UnmappableException, FilterEvaluationException { if ( !( op.getPattern() instanceof Literal ) ) { String msg = "Mapping of PropertyIsLike with non-literal comparisons to SQL is not implemented yet."; throw new UnsupportedOperationException( msg ); String literal = ( (Literal) op.getPattern() ).getValue().toString(); String escape = "" + op.getEscapeChar(); String wildCard = "" + op.getWildCard();
export( isLikeOperator.getPattern(), writer ); break; case PROPERTY_IS_NOT_EQUAL_TO:
throws UnmappableException, FilterEvaluationException { if ( !( op.getPattern() instanceof Literal ) ) { String msg = "Mapping of PropertyIsLike with non-literal comparisons to SQL is not implemented yet."; throw new UnsupportedOperationException( msg ); String literal = ( (Literal) op.getPattern() ).getValue().toString(); String escape = "" + op.getEscapeChar(); String wildCard = "" + op.getWildCard();
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() );