Filter110XMLDecoder { private static IdFilter parseIdFilter( XMLStreamReader xmlStream ) throws XMLStreamException { Set<String> matchingIds = new HashSet<String>(); QName lastIdElement = null; while ( xmlStream.getEventType() == START_ELEMENT ) { QName childElementName = xmlStream.getName(); if ( GML_OBJECT_ID_ELEMENT.equals( childElementName ) ) { if ( lastIdElement != null && !lastIdElement.equals( GML_OBJECT_ID_ELEMENT ) ) { String msg = Messages.getMessage( "FILTER_PARSER_ONLY_ONE_TYPE_OF_IDS" ); throw new XMLParsingException( xmlStream, msg ); } lastIdElement = GML_OBJECT_ID_ELEMENT; String id = xmlStream.getAttributeValue( GML_NS, "id" ); if ( id == null || id.length() == 0 ) { String msg = Messages.getMessage( "FILTER_PARSER_ID_FILTER_NO_ID", GML_OBJECT_ID_ELEMENT, GML_ID_ATTR_NAME ); throw new XMLParsingException( xmlStream, msg ); } matchingIds.add( id ); nextElement( xmlStream ); xmlStream.require( XMLStreamConstants.END_ELEMENT, OGC_NS, "GmlObjectId" ); } else if ( FEATURE_ID_ELEMENT.equals( childElementName ) ) { if ( lastIdElement != null && !lastIdElement.equals( FEATURE_ID_ELEMENT ) ) { String msg = Messages.getMessage( "FILTER_PARSER_ONLY_ONE_TYPE_OF_IDS" ); throw new XMLParsingException( xmlStream, msg ); } lastIdElement = FEATURE_ID_ELEMENT; String id = xmlStream.getAttributeValue( null, "fid" ); if ( id == null || id.length() == 0 ) { String msg = Messages.getMessage( "FILTER_PARSER_ID_FILTER_NO_ID", FEATURE_ID_ELEMENT, FID_ATTR_NAME ); throw new XMLParsingException( xmlStream, msg ); } matchingIds.add( id ); nextElement( xmlStream ); xmlStream.require( XMLStreamConstants.END_ELEMENT, OGC_NS, "FeatureId" ); } else { String msg = Messages.getMessage( "FILTER_PARSER_ID_FILTER_UNEXPECTED_ELEMENT", childElementName, GML_OBJECT_ID_ELEMENT, FEATURE_ID_ELEMENT ); throw new XMLParsingException( xmlStream, msg ); } nextElement( xmlStream ); } return new IdFilter( matchingIds ); }  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 public void parseIdFilter() throws XMLStreamException, FactoryConfigurationError, IOException { Filter filter = parse( "testfilter_110_id.xml" ); assertNotNull( filter ); Assert.assertEquals( Filter.Type.ID_FILTER, filter.getType() ); IdFilter idFilter = (IdFilter) filter; Assert.assertEquals( 4, idFilter.getMatchingIds().size() ); Assert.assertTrue( idFilter.getMatchingIds().contains( "PHILOSOPHER_966" ) ); Assert.assertTrue( idFilter.getMatchingIds().contains( "PHILOSOPHER_967" ) ); Assert.assertTrue( idFilter.getMatchingIds().contains( "PHILOSOPHER_968" ) ); Assert.assertTrue( idFilter.getMatchingIds().contains( "PHILOSOPHER_969" ) ); }