Package ch.agent.t2.time

Examples of ch.agent.t2.time.SubPeriodPattern


    return domain;
  }

  @Override
  public TimeDomain get(TimeDomainDefinition def) {
    TimeDomain domain = null;
    for (TimeDomain d : domains.values()) {
      if (((TimeFactory) d).matches(def.getBaseUnit(), def.getOrigin()
          def.getBasePeriodPattern(), def.getSubPeriodPattern())) {
        domain = d;
        break;
View Full Code Here


   *
   * @param def a non-null time domain definition
   * @return a time domain corresponding to the definition, with the label ignored, or null
   */
  private TimeDomain getTimeDomain(TimeDomainDefinition def) {
    TimeDomain domain = null;
    for (TimeDomain d : domains.values()) {
      if (((TimeFactory) d).matches(def.getBaseUnit(), def.getOrigin(),
          def.getBasePeriodPattern(), def.getSubPeriodPattern())) {
        domain = d;
        break;
View Full Code Here

    if (def.getBaseUnit() == null)
      throw new IllegalArgumentException("basePeriod");
    if (def.getSubPeriodPattern() != null && !def.getBaseUnit().equals(def.getSubPeriodPattern().getBasePeriod()))
      throw new IllegalArgumentException("basePeriods differ");
    // step 1: find domain matching required attributes
    TimeDomain domain = getTimeDomain(def);
   
    // step 2: if not found, verify that label is available, then create new domain
    if (domain == null) {
      if (def.getLabel() == null) {
        def.setLabel(inventLabel());
      } else {
        domain = domains.get(def.getLabel());
        if (domain != null) {
          Exception cause = T2Msg.exception(K.T0007, domain.toString());
          throw T2Msg.runtimeException(K.T0001, cause);
        }
      }
      ExternalTimeFormat externalFormat = getExternalTimeFormat();
      if (externalFormat == null)
View Full Code Here

      return;
    if (builtIns.length > 0) {
      int i = 0;
      for (String def : declaredBuiltIns) {
        try {
          TimeDomain d = get(def);
          ((TimeFactory) d).markBuiltIn(i);
          builtIns[i] = d;
          i++;
        } catch (T2Exception e) {
          Exception cause = T2Msg.exception(e, K.T0008, this.getClass().getCanonicalName());
View Full Code Here

  }
 
  public void testSubRangeHasNoMissingValuesAtTheBoundaries() {
    try {
      Series<Double> s = makeSeries(makeTimeSeries());
      TimeDomain dom = s.getTimeDomain();
      TimeAddressable<Double> ts = s.getValues(new Range(dom, "2011-05-15", "2011-07-15", Adjustment.NONE));
      assertEquals(new Range(dom, "2011-06-01", "2011-07-01", Adjustment.NONE), ts.getRange());
    } catch (Exception e) {
      fail(e.toString());
    }
View Full Code Here

  }
 
  public void testGetLastValue_1() {
    try {
      Series<Double> s = makeSeries(makeTimeSeries());
      TimeDomain dom = s.getTimeDomain();
      Range range = new Range(dom.time("2011-05-15"), dom.time("2011-07-15"));
      TimeAddressable<Double> ts = s.getValues(range);
      Observation<Double> obs = ts.getLast(dom.time("2011-06-01"));
      assertEquals("2011-06-01", obs.getTime().toString());
    } catch (Exception e) {
      fail(e.toString());
    }
  }
View Full Code Here

  }
 
  public void testGetLastValue_3() {
    try {
      Series<Double> s = makeSeries(makeTimeSeries());
      TimeDomain dom = s.getTimeDomain();
      Range range = new Range(dom.time("2011-05-15"), dom.time("2011-07-15"));
      TimeAddressable<Double> ts = s.getValues(range);
      Observation<Double> obs = ts.getLast(dom.time("2011-05-31"));
      assertNull(obs);
    } catch (Exception e) {
      fail(e.toString());
    }
  }
View Full Code Here

    s.applyUpdates();
    return s;
  }
 
  private TimeAddressable<Double> makeTimeSeries() throws Exception {
    TimeDomain domain = SERIES_DOMAIN;
    TimeAddressable<Double> ts = TimeSeriesFactory.make(domain, Double.class);
    ts.put(domain.time("2011-05-01"), 201105.01);
    ts.put(domain.time("2011-06-01"), 201106.01);
    ts.put(domain.time("2011-07-01"), 201107.01);
    return ts;
  }
View Full Code Here

    ts.put(domain.time("2011-06-01"), 201106.01);
    ts.put(domain.time("2011-07-01"), 201107.01);
    return ts;
  }
  private TimeAddressable<Double> makeTimeSeries2() throws Exception {
    TimeDomain domain = SERIES_DOMAIN;
    TimeAddressable<Double> ts = TimeSeriesFactory.make(domain, Double.class);
    ts.put(domain.time("2011-05-01"), 201105.01);
    ts.put(domain.time("2011-05-02"), 201105.02);
    ts.put(domain.time("2011-05-03"), 201105.03);
    ts.put(domain.time("2011-05-30"), 201105.30);
    ts.put(domain.time("2011-05-31"), 201105.31);
    ts.put(domain.time("2011-06-01"), 201106.01);
    ts.put(domain.time("2011-06-02"), 201106.02);
    ts.put(domain.time("2011-06-30"), 201106.30);
    ts.put(domain.time("2011-07-01"), 201107.01);
    ts.put(domain.time("2011-07-02"), 201107.02);
    ts.put(domain.time("2011-07-03"), 201107.03);
    return ts;
  }
View Full Code Here

    return s;
  }
 
  private Series<Double> makeSeriesWithGap(String date1, String date2) throws Exception {
    UpdatableSeries<Double> s = db.getUpdatableSeries(SERIES, true);
    TimeDomain domain = s.getTimeDomain();
    s.setValue(domain.time(date1), 1d);
    s.setValue(domain.time(date2), 2d);
    s.applyUpdates();
    return s;
  }
View Full Code Here

TOP

Related Classes of ch.agent.t2.time.SubPeriodPattern

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.