private static void export( Expression expression, XMLStreamWriter writer ) throws XMLStreamException { if ( expression != null ) { Type expressionType = expression.getType(); switch ( expressionType ) { case VALUE_REFERENCE: export( (ValueReference) expression, writer ); break; case LITERAL: export( (Literal<?>) expression, writer ); break; case FUNCTION: export( (Function) expression, writer ); break; case CUSTOM: default: throw new IllegalArgumentException( "Encoding of expression type " + expressionType + " is not supported yet!" ); } } }
private static String retrieveFilter( Filter filter ) throws XMLStreamException, FactoryConfigurationError, UnknownCRSException, TransformationException, UnsupportedEncodingException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLStreamWriter xmlWriter = null; try { xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter( bos, "UTF-8" ); Filter200XMLEncoder.export( filter, xmlWriter ); } finally { if ( xmlWriter != null ) xmlWriter.close(); } return bos.toString( "UTF-8" ); }
private static void export( Operator operator, XMLStreamWriter writer ) throws XMLStreamException, UnknownCRSException, TransformationException { switch ( operator.getType() ) { case COMPARISON: export( (ComparisonOperator) operator, writer ); break; case LOGICAL: export( (LogicalOperator) operator, writer ); break; case SPATIAL: export( (SpatialOperator) operator, writer ); break; case TEMPORAL: export( (TemporalOperator) operator, writer ); break; default: throw new IllegalArgumentException( "Encoding of operator type " + operator.getType() + " is not supported yet!" ); } }
private static void export( LogicalOperator operator, XMLStreamWriter writer ) throws XMLStreamException, UnknownCRSException, TransformationException { switch ( operator.getSubType() ) { case AND: export( writer, (And) operator ); break; case OR: export( writer, (Or) operator ); break; case NOT: export( writer, (Not) operator ); break; default: throw new IllegalArgumentException( "Encoding of logical operator subtype " + operator.getSubType() + " is not supported yet!" ); } }
private static void export( PropertyIsNull operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsNull" ); export( operator.getPropertyName(), writer ); writer.writeEndElement(); }
private static void export( XMLStreamWriter writer, Not not ) throws XMLStreamException, UnknownCRSException, TransformationException { writer.writeStartElement( FES_20_NS, "Not" ); export( not.getParameter(), 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( PropertyIsNil operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsNil" ); export( operator.getPropertyName(), writer ); writer.writeEndElement(); }
private static void export( TemporalOperator operator, XMLStreamWriter writer ) throws XMLStreamException, UnknownCRSException, TransformationException { QName elementName = temporalOperatorTypeToElementName.get( operator.getSubType() ); if ( elementName == null ) throw new IllegalArgumentException( "Encoding of temporal operator subtype " + operator.getSubType() + " is not supported yet!" ); writer.writeStartElement( elementName.getNamespaceURI(), elementName.getLocalPart() ); 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( Function function, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "Function" ); writer.writeAttribute( "name", function.getName() ); for ( Expression param : function.getParameters() ) { export( param, writer ); } 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( XMLStreamWriter writer, And andOp ) throws XMLStreamException, UnknownCRSException, TransformationException { writer.writeStartElement( FES_20_NS, "And" ); for ( int i = 0; i < andOp.getSize(); i++ ) { export( andOp.getParameter( i ), 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 static void export( PropertyIsLessThan operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsLessThan" ); 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( PropertyIsLessThanOrEqualTo operator, XMLStreamWriter writer ) throws XMLStreamException { writer.writeStartElement( FES_20_NS, "PropertyIsLessThanOrEqualTo" ); 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( XMLStreamWriter writer, Or orOp ) throws XMLStreamException, UnknownCRSException, TransformationException { writer.writeStartElement( FES_20_NS, "Or" ); for ( int i = 0; i < orOp.getSize(); i++ ) { export( orOp.getParameter( i ), writer ); } writer.writeEndElement(); }
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(); }
/** * Serializes the given {@link Filter} object to XML. * * @param filter * <code>Filter</code> object to be serialized * @param writer * target of the xml stream * @throws XMLStreamException * @throws TransformationException * @throws UnknownCRSException */ public static void export( Filter filter, XMLStreamWriter writer ) throws XMLStreamException, UnknownCRSException, TransformationException { writer.setPrefix( FES_PREFIX, FES_20_NS ); writer.writeStartElement( FES_20_NS, "Filter" ); writer.writeNamespace( FES_PREFIX, FES_20_NS ); writer.writeNamespace( GML_PREFIX, GML3_2_NS ); writer.writeNamespace( XS_PREFIX, XSINS ); writer.writeAttribute( XSINS, "schemaLocation", "http://www.opengis.net/fes/2.0 http://schemas.opengis.net/filter/2.0/filter.xsd" ); switch ( filter.getType() ) { case ID_FILTER: export( (IdFilter) filter, writer ); break; case OPERATOR_FILTER: export( ( (OperatorFilter) filter ).getOperator(), writer ); break; } writer.writeEndElement(); }