public static List<Repeater<?>> getRepeaters(List<Token> tokens) { List<Repeater<?>> repeaters = new LinkedList<Repeater<?>>(); for (Token token : tokens) { Repeater<?> tag = token.getTag(Repeater.class); if (tag != null) { repeaters.add(tag); } } Collections.sort(repeaters); Collections.reverse(repeaters); return repeaters; }
public Span handle(List<Token> tokens, Span span, Options options) { int distance = tokens.get(0).getTag(Scalar.class).getType().intValue(); Repeater<?> repeater = tokens.get(1).getTag(Repeater.class); Pointer.PointerType pointer = tokens.get(2).getTag(Pointer.class).getType(); return repeater.getOffset(span, distance, pointer); }
public Span handle(List<Token> tokens, Options options) { int month = tokens.get(0).getTag(ScalarMonth.class).getType().intValue(); int day = tokens.get(1).getTag(ScalarDay.class).getType().intValue(); Calendar start = Time.construct(options.getNow().get(Calendar.YEAR), month, day); Calendar end = Time.cloneAndAdd(start, Calendar.DAY_OF_MONTH, 1); return new Span(start, end); }
public Span handle(List<Token> tokens, Options options) { int month = tokens.get(0).getTag(ScalarMonth.class).getType().intValue(); int day = tokens.get(1).getTag(ScalarDay.class).getType().intValue(); int year = tokens.get(2).getTag(ScalarYear.class).getType().intValue(); Span span; try { List<Token> timeTokens = tokens.subList(3, tokens.size()); Calendar dayStart = Time.construct(year, month, day); span = Handler.dayOrTime(dayStart, timeTokens, options); } catch (IllegalArgumentException e) { if (options.isDebug()) { e.printStackTrace(System.out); } span = null; } return span; }
public Span handle(List<Token> tokens, Options options) { int month = tokens.get(0).getTag(RepeaterMonthName.class).getType().ordinal(); int day = tokens.get(1).getTag(ScalarDay.class).getType().intValue(); int year = tokens.get(2).getTag(ScalarYear.class).getType().intValue(); Span span; try { List<Token> timeTokens = tokens.subList(3, tokens.size()); Calendar dayStart = Time.construct(year, month, day); span = Handler.dayOrTime(dayStart, timeTokens, options); } catch (IllegalArgumentException e) { if (options.isDebug()) { e.printStackTrace(System.out); } span = null; } return span; }
public Span handle(List<Token> tokens, Options options) { int month = tokens.get(1).getTag(RepeaterMonthName.class).getType().ordinal(); int day = tokens.get(2).getTag(ScalarDay.class).getType().intValue(); int year = tokens.get(5).getTag(ScalarYear.class).getType().intValue(); Span span; try { List<Token> timeTokens = tokens.subList(3, 4); Calendar dayStart = Time.construct(year, month, day); span = Handler.dayOrTime(dayStart, timeTokens, options); } catch (IllegalArgumentException e) { if (options.isDebug()) { e.printStackTrace(System.out); } span = null; } return span; } }
public Span handle(List<Token> tokens, Options options) { int month = tokens.get(0).getTag(ScalarMonth.class).getType().intValue(); int year = tokens.get(1).getTag(ScalarYear.class).getType().intValue(); Span span; try { Calendar start = Time.construct(year, month); Calendar end = Time.cloneAndAdd(start, Calendar.MONTH, 1); span = new Span(start, end); } catch (IllegalArgumentException e) { if (options.isDebug()) { e.printStackTrace(System.out); } span = null; } return span; }
public Span handle(List<Token> tokens, Options options) { int month = tokens.get(0).getTag(RepeaterMonthName.class).getType().ordinal(); int year = tokens.get(1).getTag(ScalarYear.class).getType().intValue(); Span span; try { Calendar start = Time.construct(year, month); Calendar end = Time.cloneAndAdd(start, Calendar.MONTH, 1); span = new Span(start, end); } catch (IllegalArgumentException e) { if (options.isDebug()) { e.printStackTrace(System.out); } span = null; } return span; }
public Span handle(List<Token> tokens, Span outerSpan, Options options) { Repeater<?> repeater = tokens.get(1).getTag(Repeater.class); repeater.setStart(Time.cloneAndAdd(outerSpan.getBeginCalendar(), Calendar.SECOND, -1)); Integer ordinalValue = tokens.get(0).getTag(Ordinal.class).getType(); Span span = null; for (int i = 0; i < ordinalValue.intValue(); i++) { span = repeater.nextSpan(Pointer.PointerType.FUTURE); if (span.getBegin() > outerSpan.getEnd()) { span = null; break; } } return span; } }
public Span handle(List<Token> tokens, Options options) { Repeater<?> repeater = tokens.get(1).getTag(Repeater.class); // DIFF: Missing fortnight /* Span span; if (repeater instanceof RepeaterYear || repeater instanceof RepeaterSeason || repeater instanceof RepeaterSeasonName || repeater instanceof RepeaterMonth || repeater instanceof RepeaterMonthName || repeater instanceof RepeaterWeek) { span = chronic.parse("this hour", new Options(chronic.getNow(), false)); } else if (repeater instanceof RepeaterWeekend || repeater instanceof RepeaterDay || repeater instanceof RepeaterDayName || repeater instanceof RepeaterDayPortion || repeater instanceof RepeaterHour) { span = chronic.parse("this minute", new Options(chronic.getNow(), false)); } else if (repeater instanceof RepeaterMinute || repeater instanceof RepeaterSecond) { span = chronic.parse("this second", new Options(chronic.getNow(), false)); } else { throw new IllegalArgumentException("Invalid repeater: " + repeater); } */ Span span = Chronic.parse("this second", new Options(options.getNow(), false)); return handle(tokens, span, options); } }
for (int i = 0; dayPortionIndex == -1 && i < tokenSize; i++) { Token t = tokens.get(i); if (t.getTag(RepeaterDayPortion.class) != null) { dayPortionIndex = i; for (int i = 0; timeIndex == -1 && i < tokenSize; i++) { Token t = tokens.get(i); if (t.getTag(RepeaterTime.class) != null) { timeIndex = i; Tag<RepeaterDayPortion<?>> t1Tag = t1.getTag(RepeaterDayPortion.class); t1 = tokens.get(i + 1); if (t0.getTag(RepeaterTime.class) != null && t0.getTag(RepeaterTime.class).getType().isAmbiguous() && (t1 == null || t1.getTag(RepeaterDayPortion.class) == null)) { Token distoken = new Token("disambiguator"); distoken.tag(new IntegerRepeaterDayPortion(Integer.valueOf(options.getAmbiguousTimeRange())));
if (token.getTag(Separator.class) == null) { goodTokens.add(token); if (token.getTag(Separator.class) == null) { goodTokens.add(token); if (token.getTag(SeparatorAt.class) == null && token.getTag(SeparatorSlashOrDash.class) == null && token.getTag(SeparatorComma.class) == null) { goodTokens.add(token);