/** * Returns the length of this TM_GeometricPrimitive * * @return */ public Duration length() { Duration response = null; long diff = 0L; if (this instanceof Instant) { response = new DefaultPeriodDuration(Math.abs(diff)); return response; } else { if (this instanceof Period) { if (((Period) this).getBeginning() != null && ((Period) this).getEnding() != null) { response = ((DefaultInstant) ((Period) this).getBeginning()) .distance(((DefaultInstant) ((Period) this).getEnding())); return response; } } return null; } } }
/** Test of getBeginning method, of class DefaultPeriod. */ @Test public void testGetBeginning() { Instant result = period1.getBeginning(); assertFalse(period2.getBeginning().equals(result)); }
void visitEnd(Period p, Object extraData) { filterFactory.literal(p.getEnding().getPosition().getDate()).accept(this, extraData); }
void visitBegin(Period p, Object extraData) { filterFactory.literal(p.getBeginning().getPosition().getDate()).accept(this, extraData); }
public Object getProperty(Object object, QName name) { Period timePeriod = (Period) object; if (timePeriod == null) { return null; } if (name.getLocalPart().equals("beginPosition")) { return timePeriod.getBeginning().getPosition(); } if (name.getLocalPart().equals("endPosition")) { return timePeriod.getEnding().getPosition(); } return null; } }
/** Test of setEnding method, of class DefaultPeriod. */ @Test public void testSetEnding_Instant() { Instant result = period1.getEnding(); Instant newInstant = new DefaultInstant(new DefaultPosition(new Date())); ((DefaultPeriod) period1).setEnding(newInstant); assertFalse(period1.getEnding().equals(result)); }
/** Test of setBegining method, of class DefaultPeriod. */ @Test public void testSetBegining_Instant() { Instant result = period1.getBeginning(); Instant newInstant = new DefaultInstant(new DefaultPosition(new Date())); ((DefaultPeriod) period1).setBegining(newInstant); assertFalse(period1.getBeginning().equals(result)); }
public Object getProperty(Object object, QName name) { Period timePeriod = (Period) object; if (timePeriod == null) { return null; } if (name.getLocalPart().equals("BeginPosition")) { return timePeriod.getBeginning().getPosition(); } if (name.getLocalPart().equals("EndPosition")) { return timePeriod.getEnding().getPosition(); } return null; } }
/** Test of setBegining method, of class DefaultPeriod. */ @Test public void testSetBegining_Date() { Date result = period1.getBeginning().getPosition().getDate(); ((DefaultPeriod) period1).setBegining(new Date()); assertFalse(period1.getBeginning().getPosition().getDate().equals(result)); }
output = dateToText(period.getBeginning().getPosition().getDate(), output); output.append("/"); output = dateToText(period.getEnding().getPosition().getDate(), output);
/** * Builds an Or filter composed of During and After. * * @return Or filter * @throws CQLException */ public Or buildDuringOrAfter() throws CQLException { Period period = this.resultStack.popPeriod(); PropertyName property = this.resultStack.popPropertyName(); // makes the after filter After right = this.filterFactory.after(property, filterFactory.literal(period.getEnding())); // makes the during filter During left = this.filterFactory.during(property, this.filterFactory.literal(period)); Or filter = this.filterFactory.or(left, right); return filter; } /**
/** * Builds an Or filter composed of Before and During filters. * * @return Or filter * @throws CQLException */ public Or buildBeforeOrDuring() throws CQLException { Period period = this.resultStack.popPeriod(); PropertyName property = this.resultStack.popPropertyName(); // makes the after filter Before right = this.filterFactory.before(property, filterFactory.literal(period.getBeginning())); // makes the during filter During left = this.filterFactory.during(property, this.filterFactory.literal(period)); Or filter = this.filterFactory.or(right, left); return filter; } }
public void testParseTimePeriodByPosition() throws Exception { Parser p = new Parser(new GMLConfiguration()); Object g = p.parse(GML3ParsingTest.class.getResourceAsStream("timePeriodByPosition.xml")); assertThat(g, instanceOf(Period.class)); Period period = (Period) g; TimeZone gmt = TimeZone.getTimeZone("GMT"); java.util.Calendar calendar = java.util.Calendar.getInstance(gmt); calendar.clear(); calendar.set(2006, 5, 28, 4, 8, 0); assertEquals(calendar.getTime(), period.getBeginning().getPosition().getDate()); calendar.set(2009, 5, 28, 6, 8, 0); assertEquals(calendar.getTime(), period.getEnding().getPosition().getDate()); } }
/** * Test of getBeginning method, of class DefaultPeriod. */ @Test public void testGetBeginning() { Instant result = period1.getBeginning(); assertFalse(period2.getBeginning().equals(result)); }
.getEnding() .getPosition() .getDate() } else { if (timeobject .getEnding() .getPosition() .getDate() } else { if (timeobject .getBeginning() .getPosition() .getDate() .before(instantarg.getPosition().getDate()) && timeobject .getEnding() .getPosition() .getDate() } else { return (timeobject .getBeginning() .getPosition() .getDate() .getEnding() .getPosition()
void visitEnd(Period p, Object extraData) { filterFactory.literal(p.getEnding().getPosition().getDate()).accept(this, extraData); }
void visitBegin(Period p, Object extraData) { filterFactory.literal(p.getBeginning().getPosition().getDate()).accept(this, extraData); }