Package com.mdimension.jchronic.utils

Examples of com.mdimension.jchronic.utils.Span


      else {
        throw new IllegalArgumentException("Unable to handle pointer " + pointer + ".");
      }
    }

    return new Span(_currentMonthBegin, Calendar.MONTH, 1);
  }
View Full Code Here


    return new Span(_currentMonthBegin, Calendar.MONTH, 1);
  }

  @Override
  protected Span _thisSpan(PointerType pointer) {
    Span span;
    if (pointer == Pointer.PointerType.PAST) {
      span = nextSpan(pointer);
    }
    else if (pointer == Pointer.PointerType.FUTURE || pointer == Pointer.PointerType.NONE) {
      span = nextSpan(Pointer.PointerType.NONE);
View Full Code Here

  public void testNextFuture() {
    RepeaterWeek weeks = new RepeaterWeek();
    weeks.setStart(_now);

    Span nextWeek = weeks.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 20), nextWeek.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 27), nextWeek.getEndCalendar());

    Span nextNextWeek = weeks.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 27), nextNextWeek.getBeginCalendar());
    assertEquals(Time.construct(2006, 9, 3), nextNextWeek.getEndCalendar());
  }
View Full Code Here

  }

  public void testNextPast() {
    RepeaterWeek weeks = new RepeaterWeek();
    weeks.setStart(_now);
    Span lastWeek = weeks.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 8, 6), lastWeek.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 13), lastWeek.getEndCalendar());

    Span lastLastWeek = weeks.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 7, 30), lastLastWeek.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 6), lastLastWeek.getEndCalendar());
  }
View Full Code Here

  protected Span _nextSpan(PointerType pointer) {
    if (_currentWeekStart == null) {
      if (pointer == Pointer.PointerType.FUTURE) {
        RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
        saturdayRepeater.setStart((Calendar) getNow().clone());
        Span nextSaturdaySpan = saturdayRepeater.nextSpan(Pointer.PointerType.FUTURE);
        _currentWeekStart = nextSaturdaySpan.getBeginCalendar();
      }
      else if (pointer == Pointer.PointerType.PAST) {
        RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
        saturdayRepeater.setStart(Time.cloneAndAdd(getNow(), Calendar.SECOND, RepeaterDay.DAY_SECONDS));
        Span lastSaturdaySpan = saturdayRepeater.nextSpan(Pointer.PointerType.PAST);
        _currentWeekStart = lastSaturdaySpan.getBeginCalendar();
      }
    }
    else {
      int direction = (pointer == Pointer.PointerType.FUTURE) ? 1 : -1;
      _currentWeekStart = Time.cloneAndAdd(_currentWeekStart, Calendar.SECOND, direction * RepeaterWeek.WEEK_SECONDS);
    }
    return new Span(_currentWeekStart, Time.cloneAndAdd(_currentWeekStart, Calendar.SECOND, RepeaterWeekend.WEEKEND_SECONDS));
  }
View Full Code Here

  public void testThisFuture() {
    RepeaterWeek weeks = new RepeaterWeek();
    weeks.setStart(_now);

    Span thisWeek = weeks.thisSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 16, 15), thisWeek.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 20), thisWeek.getEndCalendar());
  }
View Full Code Here

    return new Span(_currentWeekStart, Time.cloneAndAdd(_currentWeekStart, Calendar.SECOND, RepeaterWeekend.WEEKEND_SECONDS));
  }

  @Override
  protected Span _thisSpan(PointerType pointer) {
    Span thisSpan;
    if (pointer == Pointer.PointerType.FUTURE || pointer == Pointer.PointerType.NONE) {
      RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
      saturdayRepeater.setStart((Calendar) getNow().clone());
      Span thisSaturdaySpan = saturdayRepeater.nextSpan(Pointer.PointerType.FUTURE);
      thisSpan = new Span(thisSaturdaySpan.getBeginCalendar(), Time.cloneAndAdd(thisSaturdaySpan.getBeginCalendar(), Calendar.SECOND, RepeaterWeekend.WEEKEND_SECONDS));
    }
    else if (pointer == Pointer.PointerType.PAST) {
      RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
      saturdayRepeater.setStart((Calendar) getNow().clone());
      Span lastSaturdaySpan = saturdayRepeater.nextSpan(Pointer.PointerType.PAST);
      thisSpan = new Span(lastSaturdaySpan.getBeginCalendar(), Time.cloneAndAdd(lastSaturdaySpan.getBeginCalendar(), Calendar.SECOND, RepeaterWeekend.WEEKEND_SECONDS));
    }
    else {
      throw new IllegalArgumentException("Unable to handle pointer " + pointer + ".");
    }
    return thisSpan;
View Full Code Here

  public void testThisPast() {
    RepeaterWeek weeks = new RepeaterWeek();
    weeks.setStart(_now);

    Span thisWeek = weeks.thisSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 8, 13, 0), thisWeek.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 14), thisWeek.getEndCalendar());
  }
View Full Code Here

    assertEquals(Time.construct(2006, 8, 13, 0), thisWeek.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 14), thisWeek.getEndCalendar());
  }

  public void testOffset() {
    Span span = new Span(_now, Calendar.SECOND, 1);

    Span offsetSpan = new RepeaterWeek().getOffset(span, 3, Pointer.PointerType.FUTURE);

    assertEquals(Time.construct(2006, 9, 6, 14), offsetSpan.getBeginCalendar());
    assertEquals(Time.construct(2006, 9, 6, 14, 0, 1), offsetSpan.getEndCalendar());
  }
View Full Code Here

  public Span getOffset(Span span, int amount, PointerType pointer) {
    int direction = (pointer == Pointer.PointerType.FUTURE) ? 1 : -1;
    RepeaterWeekend weekend = new RepeaterWeekend();
    weekend.setStart(span.getBeginCalendar());
    Calendar start = Time.cloneAndAdd(weekend.nextSpan(pointer).getBeginCalendar(), Calendar.SECOND, (amount - 1) * direction * RepeaterWeek.WEEK_SECONDS);
    return new Span(start, Time.cloneAndAdd(start, Calendar.SECOND, span.getWidth()));
  }
View Full Code Here

TOP

Related Classes of com.mdimension.jchronic.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.