Package ch.agent.t2.time

Examples of ch.agent.t2.time.Day


    }

    @Override
    public Day scan(String value) throws T2DBException {
      try {
        return new Day(value);
      } catch (Exception e) {
        throw T2DBMsg.exception(e, D.D10107, value, ValueType.class.getName());
      }
    }
View Full Code Here


      month = 1;
      daysInPeriod = isLeap(year) ? 366 : 365;
    } else
      daysInPeriod = daysInMonth(year, month);
    TimeIndex t = new Day(year, month, 1);
    DayOfWeek firstOfPeriod = t.getDayOfWeek();
    int workRank = rank;
    if (workRank < 0)
      workRank = max; // try the max
    int week1Offset = name.ordinal() - firstOfPeriod.ordinal();
    if (week1Offset < 0)
      week1Offset += 7;
    int dayOfPeriod = 1 + week1Offset + (workRank - 1) * 7;
    if (rank < 0) {
      if (dayOfPeriod > daysInPeriod)
View Full Code Here

        if (domain != null) {
          Exception cause = T2Msg.exception(K.T0007, domain.toString());
          throw T2Msg.runtimeException(K.T0001, cause);
        }
      }
      ExternalTimeFormat externalFormat = getExternalTimeFormat();
      if (externalFormat == null)
        externalFormat = DefaultExternalFormat.getInstance();
      domain = new TimeFactory(def, externalFormat);
      domains.put(def.getLabel(), (TimeFactory)domain);
    }
View Full Code Here

  private PreparedStatement select_range;
  private static final String SELECT_RANGE =
    "select min(date), max(date) from " + DB.VALUE_DOUBLE + " where series = ?";
  @Override
  public Range getRange(Series<Double> series) throws T2DBException {
    Range range = null;
    TimeDomain timeDomain = series.getTimeDomain();
    try {
      select_range = open(SELECT_RANGE, series, select_range);
      select_range.setInt(1, getId(series));
      ResultSet rs = select_range.executeQuery();
      if (rs.next()) {
        range = new Range(timeDomain.timeFromOffset(rs.getInt(1)), timeDomain.timeFromOffset(rs.getInt(2)));
        if (rs.wasNull())
          range = null;
      }
    } catch (Exception e) {
      throw T2DBJMsg.exception(e, J.J50122, series.getName(true));
    } finally {
      select_range = close(select_range);
    }
    if (range == null)
      range = new Range(series.getTimeDomain());
    return range;
  }
View Full Code Here

  }

  @Override
  public T getValue(TimeIndex time) throws T2Exception, T2DBException {
    checkTime(time);
    return getValues(new Range(time, time)).get(time);
  }
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

  }

  @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

TOP

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

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.