Filter110XMLDecoder { public static Filter parse( XMLStreamReader xmlStream ) throws XMLParsingException, XMLStreamException { Filter filter = null; xmlStream.require( START_ELEMENT, OGC_NS, "Filter" ); nextElement( xmlStream ); if ( xmlStream.getEventType() != START_ELEMENT ) { throw new XMLParsingException( xmlStream, Messages.getMessage( "FILTER_PARSER_FILTER_EMPTY", new QName( OGC_NS, "Filter" ) ) ); } QName elementName = xmlStream.getName(); if ( GML_OBJECT_ID_ELEMENT.equals( elementName ) || FEATURE_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( XMLStreamConstants.END_ELEMENT, OGC_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 );  }
@Test(expected = XMLParsingException.class) public void parseMixedIdFilter() throws XMLStreamException, FactoryConfigurationError, IOException { parse( "testfilter_110_id_mixed.xml" ); }
@Test public void parseOperatorFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter_110_operator.xml" ); Assert.assertNotNull( filter ); Assert.assertEquals( Filter.Type.OPERATOR_FILTER, filter.getType() ); OperatorFilter operatorFilter = (OperatorFilter) filter; Assert.assertEquals( Operator.Type.LOGICAL, operatorFilter.getOperator().getType() ); LogicalOperator logicalOperator = (LogicalOperator) operatorFilter.getOperator(); Assert.assertEquals( LogicalOperator.SubType.AND, logicalOperator.getSubType() ); And and = (And) logicalOperator; Assert.assertEquals( 2, and.getSize() ); Assert.assertEquals( Operator.Type.COMPARISON, and.getParameter( 0 ).getType() ); ComparisonOperator param1Oper = (ComparisonOperator) and.getParameter( 0 ); Assert.assertEquals( ComparisonOperator.SubType.PROPERTY_IS_GREATER_THAN, param1Oper.getSubType() ); Assert.assertEquals( Operator.Type.COMPARISON, and.getParameter( 1 ).getType() ); ComparisonOperator param2Oper = (ComparisonOperator) and.getParameter( 1 ); Assert.assertEquals( ComparisonOperator.SubType.PROPERTY_IS_EQUAL_TO, param2Oper.getSubType() ); }
@Test(expected = XMLParsingException.class) public void parseBrokenIdFilterDocument() throws XMLStreamException, FactoryConfigurationError, IOException { parse( "testfilter_110_id.invalid_xml" ); }
@Test(expected = XMLParsingException.class) public void parseBrokenIdFilterDocument2() throws XMLStreamException, FactoryConfigurationError, IOException { parse( "testfilter_110_id2.invalid_xml" ); }
@Test public void parseAndExportFilterDocument() throws XMLStreamException, FactoryConfigurationError, IOException, UnknownCRSException, TransformationException { Filter filter = parse( "testfilter_110_operator.xml" ); XMLMemoryStreamWriter writer = new XMLMemoryStreamWriter(); Filter110XMLEncoder.export( filter, writer.getXMLStreamWriter() ); String schemaLocation = "http: XMLAssert.assertValidity( writer.getReader(), schemaLocation ); }
@Test public void parseBeyondFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter15.xml" ); Assert.assertNotNull( filter ); }
@Test public void parseDisjointFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter16.xml" ); Assert.assertNotNull( filter ); }
@Test public void parseContainsFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter17.xml" ); Assert.assertNotNull( filter ); }
@Test public void parseCrossesFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter18.xml" ); Assert.assertNotNull( filter ); }
@Test public void parseDWithinFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter19.xml" ); Assert.assertNotNull( filter ); }
@Test public void parseIntersectsFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter20.xml" ); Assert.assertNotNull( filter ); }
@Test public void parseEqualsFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter21.xml" ); Assert.assertNotNull( filter ); }
@Test public void parseOverlapsFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter22.xml" ); Assert.assertNotNull( filter ); }
@Test public void parseTouchesFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter23.xml" ); Assert.assertNotNull( filter ); }
@Test public void parseWithinFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter24.xml" ); Assert.assertNotNull( filter ); }