@Override public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return new RelativeTime(PREV_IMMEDIATE, arg2);
@Override public Map<String, String> getTimexAttributes(TimeIndex timeIndex) { Map<String, String> map = super.getTimexAttributes(timeIndex); String tfid = getTfidString(timeIndex); map.put(TimexAttr.temporalFunction.name(), "true"); map.put(TimexAttr.valueFromFunction.name(), tfid); if (base != null) { map.put(TimexAttr.anchorTimeID.name(), base.getTidString(timeIndex)); } return map; }
@Override public String toFormattedString(int flags) { if (getTimeLabel() != null) { return getTimeLabel(); } if ((flags & FORMAT_ISO) != 0) { return null; } // TODO: is there iso standard? if ((flags & FORMAT_TIMEX3_VALUE) != 0) { return null; } // TODO: is there timex3 standard? StringBuilder sb = new StringBuilder(); if (base != null && base != TIME_REF) { sb.append(base.toFormattedString(flags)); } if (tempOp != null) { if (sb.length() > 0) { sb.append(" "); } sb.append(tempOp); if (tempArg != null) { sb.append(" ").append(tempArg.toFormattedString(flags)); } } return sb.toString(); }
t = new RelativeTime(p, new DurationWithFields(unsupported)); t.approx = this.approx; t.mod = this.mod;
if (t != null) { t = t.addModApprox(mod, approx); if (!this.equals(t)) { return t.resolve(refTime, flags); } else {
if (t != null) { t = t.addModApprox(mod, approx); if (!this.equals(t)) { return t.resolve(refTime, flags); } else {
if (t != null) { t = t.addModApprox(mod, approx); if (!this.equals(t)) { return t.resolve(refTime, flags); } else {
@Override public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return new RelativeTime(PREV_IMMEDIATE, arg2);
public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return new RelativeTime(PREV_IMMEDIATE, arg2); } if (arg2 == null) { return arg1; } // Temporal arg2Prev = arg2.prev(); // if (arg1 == null || arg2Prev == null) { return arg2Prev; } if (arg1 instanceof Time) { Time t = (Time) arg1; if (arg2 instanceof Duration) { return ((Duration) arg2).toTime(t, flags | RESOLVE_TO_PAST); } else { // TODO: flags? Temporal resolvedThis = arg2.resolve(t, RESOLVE_TO_PAST); if (resolvedThis != null) { if (resolvedThis instanceof Time) { if (((Time) resolvedThis).compareTo(t) >= 0) { return PREV.apply(arg1, arg2); } } } return resolvedThis; } } else { throw new UnsupportedOperationException("PREV_IMMEDIATE not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return new RelativeTime(NEXT_IMMEDIATE, arg2); } if (arg2 == null) { return arg1; } // Temporal arg2Next = arg2.next(); // if (arg1 == null || arg2Next == null) { return arg2Next; } if (arg1 instanceof Time) { Time t = (Time) arg1; if (arg2 instanceof Duration) { return ((Duration) arg2).toTime(t, flags | RESOLVE_TO_FUTURE); } else { // TODO: flags? Temporal resolvedThis = arg2.resolve(t, RESOLVE_TO_FUTURE); if (resolvedThis != null) { if (resolvedThis instanceof Time) { if (((Time) resolvedThis).compareTo(t) <= 0) { return NEXT.apply(arg1, arg2); } } } return resolvedThis; } } else { throw new UnsupportedOperationException("NEXT_IMMEDIATE not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return new RelativeTime(PREV_IMMEDIATE, arg2); } if (arg2 == null) { return arg1; } // Temporal arg2Prev = arg2.prev(); // if (arg1 == null || arg2Prev == null) { return arg2Prev; } if (arg1 instanceof Time) { Time t = (Time) arg1; if (arg2 instanceof Duration) { return ((Duration) arg2).toTime(t, flags | RESOLVE_TO_PAST); } else { // TODO: flags? Temporal resolvedThis = arg2.resolve(t, RESOLVE_TO_PAST); if (resolvedThis != null) { if (resolvedThis instanceof Time) { if (((Time) resolvedThis).compareTo(t) >= 0) { return PREV.apply(arg1, arg2); } } } return resolvedThis; } } else { throw new UnsupportedOperationException("PREV_IMMEDIATE not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return new RelativeTime(NEXT_IMMEDIATE, arg2); } if (arg2 == null) { return arg1; } // Temporal arg2Next = arg2.next(); // if (arg1 == null || arg2Next == null) { return arg2Next; } if (arg1 instanceof Time) { Time t = (Time) arg1; if (arg2 instanceof Duration) { return ((Duration) arg2).toTime(t, flags | RESOLVE_TO_FUTURE); } else { // TODO: flags? Temporal resolvedThis = arg2.resolve(t, RESOLVE_TO_FUTURE); if (resolvedThis != null) { if (resolvedThis instanceof Time) { if (((Time) resolvedThis).compareTo(t) <= 0) { return NEXT.apply(arg1, arg2); } } } return resolvedThis; } } else { throw new UnsupportedOperationException("NEXT_IMMEDIATE not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
@Override public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return new RelativeTime(NEXT_IMMEDIATE, arg2);
@Override public String toFormattedString(int flags) { if (getTimeLabel() != null) { return getTimeLabel(); } if ((flags & FORMAT_ISO) != 0) { return null; } // TODO: is there iso standard? if ((flags & FORMAT_TIMEX3_VALUE) != 0) { return null; } // TODO: is there timex3 standard? StringBuilder sb = new StringBuilder(); if (base != null && base != TIME_REF) { sb.append(base.toFormattedString(flags)); } if (tempOp != null) { if (sb.length() > 0) { sb.append(" "); } sb.append(tempOp); if (tempArg != null) { sb.append(" ").append(tempArg.toFormattedString(flags)); } } return sb.toString(); }
public String toFormattedString(int flags) { if (getTimeLabel() != null) { if (getTimeLabel().isoString != null) { return getTimeLabel().isoString; } } if ((flags & FORMAT_ISO) != 0) { return null; } // TODO: is there iso standard? if ((flags & FORMAT_TIMEX3_VALUE) != 0) { return null; } // TODO: is there timex3 standard? StringBuilder sb = new StringBuilder(); if (base != null && base != TIME_REF) { sb.append(base.toFormattedString(flags)); } if (tempOp != null) { if (sb.length() > 0) { sb.append(" "); } sb.append(tempOp).append(" "); sb.append(tempArg.toFormattedString(flags)); } return sb.toString(); }
public String toFormattedString(int flags) { if (getTimeLabel() != null) { return getTimeLabel(); } if ((flags & FORMAT_ISO) != 0) { return null; } // TODO: is there iso standard? if ((flags & FORMAT_TIMEX3_VALUE) != 0) { return null; } // TODO: is there timex3 standard? StringBuilder sb = new StringBuilder(); if (base != null && base != TIME_REF) { sb.append(base.toFormattedString(flags)); } if (tempOp != null) { if (sb.length() > 0) { sb.append(" "); } sb.append(tempOp); if (tempArg != null) { sb.append(" ").append(tempArg.toFormattedString(flags)); } } return sb.toString(); }
public Time add(Duration offset) { Time t; Duration d = offset; if (this.tempOp == null) { t = new RelativeTime(base, d); t.approx = this.approx; t.mod = this.mod; } else if (this.tempOp == TemporalOp.OFFSET) { d = ((Duration) this.tempArg).add(offset); t = new RelativeTime(base, d); t.approx = this.approx; t.mod = this.mod; } else { t = new RelativeTime(this, d); } return t; }
public Temporal intersect(Temporal t) { if (t == null) return this; if (t == TIME_UNKNOWN || t == DURATION_UNKNOWN) return this; if (t instanceof Time) { RelativeTime rt = new RelativeTime((Time) t, TemporalOp.INTERSECT, this); rt = (RelativeTime) rt.addMod(this.getMod()); return rt; } else if (t instanceof Range) { // return new TemporalSet(t, TemporalOp.INTERSECT, this); } else if (t instanceof Duration) { Duration d = (Duration) t; return intersect(d); } return null; }
@Override public Temporal intersect(Temporal t) { if (t == null) return this; if (t == TIME_UNKNOWN || t == DURATION_UNKNOWN) return this; if (t instanceof Time) { RelativeTime rt = new RelativeTime((Time) t, TemporalOp.INTERSECT, this); rt = (RelativeTime) rt.addMod(this.getMod()); return rt; } else if (t instanceof Range) { // return new TemporalSet(t, TemporalOp.INTERSECT, this); } else if (t instanceof Duration) { Duration d = (Duration) t; return intersect(d); } return null; }
@Override public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return new RelativeTime(THIS, arg2, flags); } if (arg1 instanceof Time) { if (arg2 instanceof Duration) { return ((Duration) arg2).toTime((Time) arg1, flags); } else { // TODO: flags? return arg2.resolve((Time) arg1, flags | RESOLVE_TO_THIS); } } else { throw new UnsupportedOperationException("THIS not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },