Package er.chronic.utils

Examples of er.chronic.utils.Span


public class SyHandler implements IHandler {

  public Span handle(List<Token> tokens, Options options) {
    int year = tokens.get(0).getTag(ScalarYear.class).getType().intValue();

    Span span;
    try {
      Calendar dayStart = Time.construct(year, 1, 1);
      List<Token> timeTokens = tokens.subList(1, tokens.size());
      span = Handler.dayOrTime(dayStart, timeTokens, options);
      // make the year span last a year rather than a day
      if (!options.isGuess()) {
        Calendar beginCalendar = span.getBeginCalendar();
        span = new Span(beginCalendar, Time.cloneAndAdd(beginCalendar, Calendar.YEAR, 1));
      }
    } catch (IllegalArgumentException e) {
      if (options.isDebug()) {
        e.printStackTrace(System.out);
      }
View Full Code Here


import er.chronic.utils.Token;

public class ORGRHandler extends ORRHandler {

  public Span handle(List<Token> tokens, Options options) {
    Span outerSpan = Handler.getAnchor(tokens.subList(2, 4), options);
    return handle(tokens.subList(0, 2), outerSpan, options);
  }
View Full Code Here

public class SmSyHandler implements IHandler {
  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);
      }
View Full Code Here

  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);
      }
View Full Code Here

public class SRPAHandler extends SRPHandler {

  @Override
  public Span handle(List<Token> tokens, Options options) {
    Span anchorSpan = Handler.getAnchor(tokens.subList(3, tokens.size()), options);
    return super.handle(tokens, anchorSpan, options);
  }
View Full Code Here

public abstract class ORRHandler implements IHandler {
  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;
View Full Code Here

import er.chronic.utils.Token;

public abstract class MDHandler implements IHandler {
  public Span handle(Repeater<?> month, Tag<? extends Number> day, List<Token> timeTokens, Options options) {
    month.setStart((Calendar) options.getNow().clone());
    Span span = month.thisSpan(options.getContext());
    Calendar dayStart = Time.construct(span.getBeginCalendar().get(Calendar.YEAR), span.getBeginCalendar().get(Calendar.MONTH) + 1, day.getType().intValue());
    return Handler.dayOrTime(dayStart, timeTokens, options);
  }
View Full Code Here

    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);
    }
View Full Code Here

    }

    Repeater<?> head = repeaters.remove(0);
    head.setStart((Calendar) options.getNow().clone());

    Span outerSpan;
    Grabber.Relative grabberType = grabber.getType();
    if (grabberType == Grabber.Relative.LAST) {
      outerSpan = head.nextSpan(Pointer.PointerType.PAST);
    }
    else if (grabberType == Grabber.Relative.THIS) {
      if (repeaters.size() > 0) {
        outerSpan = head.thisSpan(PointerType.NONE);
      }
      else {
        outerSpan = head.thisSpan(options.getContext());
      }
    }
    else if (grabberType == Grabber.Relative.NEXT) {
      outerSpan = head.nextSpan(Pointer.PointerType.FUTURE);
    }
    else {
      throw new IllegalArgumentException("Invalid grabber type " + grabberType + ".");
    }

    if (options.isDebug()) {
      System.out.println("Chronic.getAnchor: grabber = " + grabber + "; repeaters = " + repeaters + "; outerSpan = " + outerSpan);
    }

    Span anchor = findWithin(repeaters, outerSpan, pointer, options);
    return anchor;
  }
View Full Code Here

  //def endian_variable_name_for(e)
  //def swap(arr, a, b); arr[a], arr[b] = arr[b], arr[a]; end

  public static Span parseTime(List<Token> tokens, int timeTokenOffset, int year, int month, int day, Options options) {
    // MS: properly parse time in this format
    Span span;
    try {
      List<Token> timeTokens = tokens.subList(timeTokenOffset, tokens.size());
      Calendar dayStart = Time.construct(year, month, day);
      span = Handler.dayOrTime(dayStart, timeTokens, options);
    }
View Full Code Here

TOP

Related Classes of er.chronic.utils.Span

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.