Filter200XMLDecoder { public static Filter parse( XMLStreamReader xmlStream ) throws XMLParsingException, XMLStreamException { Filter filter = null; xmlStream.require( START_ELEMENT, FES_NS, "Filter" ); nextElement( xmlStream ); if ( xmlStream.getEventType() != START_ELEMENT ) { throw new XMLParsingException( xmlStream, Messages.getMessage( "FILTER_PARSER_FILTER_EMPTY", new QName( FES_NS, "Filter" ) ) ); } QName elementName = xmlStream.getName(); if ( RESOURCE_ID_ELEMENT.equals( elementName ) ) { LOG.debug( "Building id filter" ); filter = parseIdFilter( xmlStream ); } else { LOG.debug( "Building operator filter" ); Operator rootOperator = parseOperator( xmlStream ); filter = new OperatorFilter( rootOperator ); nextElement( xmlStream ); } xmlStream.require( END_ELEMENT, FES_NS, "Filter" ); return filter; }  static Filter parse( XMLStreamReader xmlStream ); static Expression parseExpression( XMLStreamReader xmlStream ); static Function parseFunction( XMLStreamReader xmlStream ); static CustomExpression parseCustomExpression( XMLStreamReader xmlStream ); static ComparisonOperator parseComparisonOperator( XMLStreamReader xmlStream ); static TemporalOperator parseTemporalOperator( final XMLStreamReader xmlStream );  }
@Test public void parseOGCExample03() throws XMLStreamException, FactoryConfigurationError, IOException { URL[] urls = getUrls( "filter03.xml" ); for ( int i = 1; i < urls.length; i++ ) { InputStream is = urls[i].openStream(); XMLStreamReader xmlStream = XMLInputFactory.newInstance().createXMLStreamReader( is ); XMLStreamUtils.skipStartDocument( xmlStream ); Filter filter = Filter200XMLDecoder.parse( xmlStream ); Not not = (Not) ( (OperatorFilter) filter ).getOperator(); Disjoint op = (Disjoint) not.getParameter(); ValueReference valRef = (ValueReference) op.getParam1(); Assert.assertEquals( "Geometry", valRef.getAsText() ); Assert.assertEquals( new QName( "Geometry" ), valRef.getAsQName() ); Envelope env = (Envelope) op.getGeometry(); } }
@Test(expected = XMLParsingException.class) public void parsePropertyIsLessThanOrEuqlToWithLiteralContainingUnexpectedGeometry() throws Exception { InputStream filterAsStream = this.getClass().getResourceAsStream( "v200/unexectedTestfilter.xml" ); XMLStreamReader xmlStream = XMLInputFactory.newInstance().createXMLStreamReader( filterAsStream ); XMLStreamUtils.skipStartDocument( xmlStream ); Filter200XMLDecoder.parse( xmlStream ); }