Package ch.agent.t2.time

Examples of ch.agent.t2.time.TimeIndex


   * @param context non-null range
   * @return a range
   * @throws T2Exception
   */
  public Range getRange(Range context) throws T2Exception {
    TimeDomain contextDomain = context.getTimeDomain();
    if (beginExpr == null) {
      return new Range(contextDomain);
    } else {
      // be more permissive with context and fix ranges invalidated by conversion
      TimeIndex begin = beginExpr.getDate(context);
View Full Code Here


    } else {
      int compareResols = getTimeDomain().getResolution().compareTo(otherTime.getTimeDomain().getResolution());
      if (compareResols == 0) {
        // convert  both to unrestricted domain
        TimeDomainDefinition def = new TimeDomainDefinition(null, getTimeDomain().getResolution(), 0L);
        TimeDomain unrestrictedDomain = TimeDomainManager.getFactory().get(def, true);
        TimeIndex converted = convertOrThrowRTE(unrestrictedDomain, this);
        TimeIndex otherConverted = convertOrThrowRTE(unrestrictedDomain, otherTime);
        return converted.compareTo(otherConverted);
      } else if (compareResols < 0) {
        // convert  both to highest resolution
        TimeDomainDefinition def = new TimeDomainDefinition(null, otherTime.getTimeDomain().getResolution(), 0L);
        TimeDomain unrestrictedDomain = TimeDomainManager.getFactory().get(def, true);
        TimeIndex converted = convertOrThrowRTE(unrestrictedDomain, this);
        return converted.compareTo(otherTime);
      } else {
        // convert  both to highest resolution
        TimeDomainDefinition def = new TimeDomainDefinition(null, getTimeDomain().getResolution(), 0L);
        TimeDomain unrestrictedDomain = TimeDomainManager.getFactory().get(def, true);
        TimeIndex otherConverted = convertOrThrowRTE(unrestrictedDomain, otherTime);
        return compareTo(otherConverted);
      }
    }
  }
View Full Code Here

    return d;
  }

  @Override
  public TimeDomain get(String label) throws T2Exception {
    TimeDomain domain = domains.get(label);
    if (domain == null)
      throw T2Msg.exception(K.T0006, label, getTimeDomainLabels().toString());
    return domain;
  }
View Full Code Here

    return domain;
  }
 
  @Override
  public TimeDomain get(TimeDomainDefinition def, boolean register) {
    TimeDomain domain = get(def);
    if (domain == null) {
      if (register)
        domain = define(def);
    } else {
      if (def.getLabel() != null && !domain.getLabel().equals(def.getLabel())) {
        Exception cause = T2Msg.exception(K.T0009, domain.toString(),  def.getLabel());
        throw T2Msg.runtimeException(K.T0001, cause);
      }
    }
    return domain;
  }
View Full Code Here

    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

        return 0;
    } else {
      int compareResols = getTimeDomain().getResolution().compareTo(otherTime.getTimeDomain().getResolution());
      if (compareResols == 0) {
        // convert  both to unrestricted domain
        TimeDomainDefinition def = new TimeDomainDefinition(null, getTimeDomain().getResolution(), 0L);
        TimeDomain unrestrictedDomain = TimeDomainManager.getFactory().get(def, true);
        TimeIndex converted = convertOrThrowRTE(unrestrictedDomain, this);
        TimeIndex otherConverted = convertOrThrowRTE(unrestrictedDomain, otherTime);
        return converted.compareTo(otherConverted);
      } else if (compareResols < 0) {
        // convert  both to highest resolution
        TimeDomainDefinition def = new TimeDomainDefinition(null, otherTime.getTimeDomain().getResolution(), 0L);
        TimeDomain unrestrictedDomain = TimeDomainManager.getFactory().get(def, true);
        TimeIndex converted = convertOrThrowRTE(unrestrictedDomain, this);
        return converted.compareTo(otherTime);
      } else {
        // convert  both to highest resolution
        TimeDomainDefinition def = new TimeDomainDefinition(null, getTimeDomain().getResolution(), 0L);
        TimeDomain unrestrictedDomain = TimeDomainManager.getFactory().get(def, true);
        TimeIndex otherConverted = convertOrThrowRTE(unrestrictedDomain, otherTime);
        return compareTo(otherConverted);
      }
    }
View Full Code Here

        select_first_double2.setInt(2, sid);
        rs = select_first_double2.executeQuery();
      }
      if (rs.next()) {
        TimeDomain dom = time == null ? series.getTimeDomain() : time.getTimeDomain();
        TimeIndex t = dom.timeFromOffset(rs.getInt(1));
        obs = new Observation<Double>(t, rs.getDouble(2));
      }
    } catch (Exception e) {
        throw T2DBJMsg.exception(e, J.J50123, series.getName(true), time.toString());
    } finally {
View Full Code Here

TOP

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

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.