Package ch.agent.t2.time

Examples of ch.agent.t2.time.TimeIndex


    return r == null || r.isInRange(t);
  }
 
  @Override
  public Range getRange() throws T2Exception, T2DBException {
    Range result = super.getRange();
    if (range != null)
      result = result.intersection(range);
    else {
      if (updates != null) {
        result = result.union(updates.getRange());
      }
      if (deletes != null) {
        boolean tryHarder = false;
        for (TimeIndex t : deletes) {
          if (t.asLong() == result.getFirstIndex() || t.asLong() == result.getLastIndex()) {
            tryHarder = true;
            break;
          }
        }
        if (tryHarder) {
View Full Code Here


    if (getSurrogate().inConstruction())
      throw T2DBMsg.exception(D.D50111, getName(true));
    if (delete || updates != null || deletes != null)
      throw T2DBMsg.exception(D.D50110, getName(true));
    if (range == null)
      range = new Range(getTimeDomain()); // (= set empty range)
    boolean inRange = range.isEmpty() || getRange().isInRange(range);
    if (inRange)
      this.range = range;
    return inRange;
  }
View Full Code Here

  }

  @Override
  public void willDelete(UpdatableSeries<?> series) throws T2DBException {
    try {
      Range range = series.getRange();
      if (!range.isEmpty())
        throw T2DBMsg.exception(D.D50130, series.getName(true), range.toString());
    } catch (T2Exception e) {
      throw T2DBMsg.exception(e, D.D50102, series.getName(true));
    }
    if (extension != null)
      extension.willDelete(series);
View Full Code Here

    return r == null || r.isInRange(t);
  }
 
  @Override
  public Range getRange() throws T2Exception, T2DBException {
    Range result = super.getRange();
    if (range != null)
      result = result.intersection(range);
    else {
      if (updates != null) {
        result = result.union(updates.getRange());
      }
      if (deletes != null) {
        boolean tryHarder = false;
        for (TimeIndex t : deletes) {
          if (t.asLong() == result.getFirstIndex() || t.asLong() == result.getLastIndex()) {
            tryHarder = true;
            break;
          }
        }
        if (tryHarder) {
View Full Code Here

    if (getSurrogate().inConstruction())
      throw T2DBMsg.exception(D.D50111, getName(true));
    if (delete || updates != null || deletes != null)
      throw T2DBMsg.exception(D.D50110, getName(true));
    if (range == null)
      range = new Range(getTimeDomain()); // (= set empty range)
    boolean inRange = range.isEmpty() || getRange().isInRange(range);
    if (inRange)
      this.range = range;
    return inRange;
  }
View Full Code Here

        if (mvStart > 0) {
          // i.e. don't interpolate when first element is a missing value
          try {
            interpolator.fillHole(val, mvStart - 1, i);
          } catch (Exception e) {
            Range range = new Range(getTimeDomain(), getFirstIndex() + mvStart,  getFirstIndex() + i - 1);
            throw T2Msg.exception(e, K.T5017, range.toString());
          }
          for (int j = mvStart; j < i; j++) {
            val[j] = normalizeMissingValue(val[j]);
          }
        }
View Full Code Here

  @Override
  public Range getRange() {
    // do not cache the (immutable) range object, the actual range can change
    if (getSize() < 1)
      return new Range(domain);
    else
      return new Range(domain, internalGetFirstIndex(), internalGetLastIndex());
  }
View Full Code Here

    internalRemove(t.asLong());
  }

  @Override
  public boolean setRange(Range range) throws T2Exception {
    Range current = getRange();
    if (current.isEmpty())
      return false;
    if (current.equals(range))
      return false;
    if (range == null) {
      internalClear();
      return true;
    }
    Range inter = current.intersection(range);
    if (inter.isEmpty()) {
      internalClear();
      return true;
    } else if (inter.equals(current)) {
      return false;
    } else {
      internalSetBounds(inter.getFirstIndex(), inter.getLastIndex());
      return true;
    }

  }
View Full Code Here

   * @return a range
   * @throws T2Exception
   */
  public Range getRange(TimeDomain context) throws T2Exception {
    if (beginExpr == null)
      return new Range(context);
    else
      return new Range(beginExpr.getDate(context), endExpr.getDate(context));
  }
View Full Code Here

   * @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);
      TimeIndex end = endExpr.getDate(context);
      if (begin == null || end == null) // (consequence of empty context range when context needed)
        return new Range(contextDomain);
      else if (begin.compareTo(end) > 0 && (beginExpr.needContext() || endExpr.needContext()))
        return new Range(contextDomain);
      else {
        /*
         * There is a possibly that a valid range has been converted
         * into an invalid one. Typical case: daily(Sat, Sat) turned
         * into MoFr(Mon,Fri) because of adjustments. As this is not
         * the intended effect of adjustments, the problem is fixed
         * silently here.
         */
        if (begin.compareTo(end) > 0 && beginAdj == Adjustment.UP) {
          beginExpr.setTime(end);
          begin = beginExpr.getDate(context);
        }
        return new Range(begin, end);
      }
    }
  }
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.