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; } }
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; } }
/** * 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; } } }
output = dateToText(period.getEnding().getPosition().getDate(), output);
void visitEnd(Period p, Object extraData) { filterFactory.literal(p.getEnding().getPosition().getDate()).accept(this, extraData); }
/** 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)); }
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()); } }
/** * 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; } /**
Math.abs( ((Period) other) .getEnding() .getPosition() .getDate() ((Instant) other).getPosition().getDate().getTime() - ((Period) this) .getEnding() .getPosition() .getDate() Math.abs( ((Period) other) .getEnding() .getPosition() .getDate() .getTime() - ((Period) this) .getEnding() .getPosition() .getDate()
.getEnding() .getPosition() .getDate() } else { if (timeobject .getEnding() .getPosition() .getDate() .before(instantarg.getPosition().getDate()) && timeobject .getEnding() .getPosition() .getDate() .getEnding() .getPosition() .getDate() } else { if (instantarg .getEnding() .getPosition() .getDate() .before(timeobject.getPosition().getDate()) && instantarg .getEnding()
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object The Instant to copy values from, or {@code null} if none. * * @see #castOrCopy(Period) */ private DefaultPeriod(final Period object) { super(object); if (object != null) { begining = object.getBeginning(); ending = object.getEnding(); if (object instanceof DefaultPeriod) { //--- voir pour get duration } } }
/** * 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; } } }
void visitEnd(Period p, Object extraData) { filterFactory.literal(p.getEnding().getPosition().getDate()).accept(this, extraData); }
void visitEnd(Period p, Object extraData) { filterFactory.literal(p.getEnding().getPosition().getDate()).accept(this, extraData); }
/** * Test of setEnding method, of class DefaultPeriod. */ @Test public void testSetEnding_Instant() { NamedIdentifier name = new NamedIdentifier(null, "Ending"); final Map<String, Object> properties = new HashMap<>(); properties.put(IdentifiedObject.NAME_KEY, name); Instant result = period1.getEnding(); Instant newInstant = new DefaultInstant(properties, new Date()); ((DefaultPeriod) period1).setEnding(newInstant); assertFalse(period1.getEnding().equals(result)); }
/** * 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; } /**
/** {@inheritDoc} */ @Override public Object visit(During during, Object userData) { String propertyName = getPropertyName(during.getExpression1()); String finalName = parsePropertyName(propertyName, userData); Object literal = getLiteralValue(during.getExpression2()); if (literal instanceof Period) { Period p = (Period) literal; Date begin = p.getBeginning().getPosition().getDate(); Date end = p.getEnding().getPosition().getDate(); return Restrictions.between(finalName, begin, end); } else { throw new UnsupportedOperationException("visit(Object userData)"); } }