Exemplo n.º 1
0
  /**
   * Returns all values since last check and removes values from the queue.
   *
   * @return a new array with the value; never null
   */
  @Override
  public List<T> getValue() {
    synchronized (buffer) {
      if (buffer.isEmpty()) return Collections.emptyList();

      // period allowed time = latest - msCache / 1000
      TimeInterval periodAllowed =
          cachedPeriod.before(TimeStamp.asTimestamp(TimeSupport.timestampOf(buffer.getLast())));
      while (!buffer.isEmpty()
          && !periodAllowed.contains(
              TimeStamp.asTimestamp(TimeSupport.timestampOf(buffer.getFirst())))) {
        // Discard value
        buffer.removeFirst();
      }
      return new ArrayList<T>(buffer);
    }
  }
Exemplo n.º 2
0
 @Override
 public BigDecimal marshal(TimeStamp v) throws Exception {
   return new BigDecimal(v.getNanoSec()).scaleByPowerOfTen(-9).add(new BigDecimal(v.getSec()));
 }
Exemplo n.º 3
0
 @Override
 public TimeStamp unmarshal(BigDecimal v) throws Exception {
   return TimeStamp.time(
       v.longValue(), v.remainder(new BigDecimal(1)).scaleByPowerOfTen(9).intValue());
 }