GmlTimePeriodReader extends AbstractGmlTimeGeometricPrimitiveReader { public TimePeriod read( final XMLStreamReader xmlStream ) throws XMLStreamException { final String gmlId = parseGmlId( xmlStream ); final String frame = getAttributeValue( xmlStream, FRAME ); final List<Property> props = readGmlStandardProperties( xmlStream ); final List<RelatedTime> relatedTimes = readRelatedTimes( xmlStream ); final TimePositionOrInstant begin = readRequiredBeginOrBeginPosition( xmlStream ); final TimePositionOrInstant end = readRequiredEndOrEndPosition( xmlStream ); nextElement( xmlStream ); skipDurationIfPresent( xmlStream ); skipTimeIntervalIfPresent( xmlStream ); return new GenericTimePeriod( gmlId, props, relatedTimes, frame, begin, end ); } GmlTimePeriodReader( final GMLStreamReader gmlStreamReader ); TimePeriod read( final XMLStreamReader xmlStream );  }
@Test public void readMinimalExample() throws Exception { final GMLStreamReader reader = getGmlStreamReader( "time_period_minimal.gml" ); final XMLStreamReader xmlStream = reader.getXMLReader(); final TimePeriod timePeriod = new GmlTimePeriodReader( reader ).read( xmlStream ); assertNotNull( timePeriod ); assertEquals( "p1", timePeriod.getId() ); assertNull( timePeriod.getFrame() ); final TimePosition begin = (TimePosition) timePeriod.getBegin(); assertEquals( "2001-05-23", begin.getValue() ); final TimePosition end = (TimePosition) timePeriod.getEnd(); assertEquals( "2001-06-23", end.getValue() ); assertOnEndElement( xmlStream ); }
@Test public void readFullExample() throws Exception { final GMLStreamReader reader = getGmlStreamReader( "time_period_full.gml" ); final XMLStreamReader xmlStream = reader.getXMLReader(); final TimePeriod timePeriod = new GmlTimePeriodReader( reader ).read( xmlStream ); assertNotNull( timePeriod ); assertEquals( "p1", timePeriod.getId() ); assertNull( timePeriod.getFrame() ); final TimeInstant begin = (TimeInstant) timePeriod.getBegin(); assertEquals( "2001-05-23", begin.getPosition().getValue() ); final TimeInstant end = (TimeInstant) timePeriod.getEnd(); assertEquals( "2001-06-23", end.getPosition().getValue() ); assertOnEndElement( xmlStream ); }
@Test public void readMixedXlinkExample() throws Exception { final GMLStreamReader reader = getGmlStreamReader( "time_period_mixed_xlink.gml" ); final XMLStreamReader xmlStream = reader.getXMLReader(); final TimePeriod timePeriod = new GmlTimePeriodReader( reader ).read( xmlStream ); assertNotNull( timePeriod ); assertEquals( "p22", timePeriod.getId() ); assertNull( timePeriod.getFrame() ); final TimeInstantReference begin = (TimeInstantReference) timePeriod.getBegin(); assertEquals( "#t11", begin.getURI() ); final TimePosition end = (TimePosition) timePeriod.getEnd(); assertEquals( "2002-05-23", end.getValue() ); assertOnEndElement( xmlStream ); }