示例#1
0
  /** Gets given data into this object. */
  public void merge(final ParseResult other) {
    if (this.calendars.size() == 0) {
      this.calendars.add((Calendar) other.getLocalTimestamp(0).clone());
    }
    if (!other.getUTCTimestampCopy().equals(this.getUTCTimestampCopy())) {
      throw new IllegalArgumentException(
          "Cannot merge result data in "
              //            System.out.println("Cannot merge result data in "
              + "different times ("
              + other.getUTCTimestampCopy()
              + " is not as expected "
              + this.getUTCTimestampCopy()
              + ")\n"
              + "Original result is related to "
              + this.symbols
              + " and "
              + "unexpected result is related to "
              + other.symbols);
    }

    for (Map.Entry<String, Map<Field, Double>> symbolVals : other.values.entrySet()) {
      boolean symbolFound = false;
      for (int i = 0; i < this.symbols.size(); i++) {
        if (this.symbols.get(i).equals(symbolVals.getKey())) {
          symbolFound = true;
          break;
        }
      }
      if (!symbolFound) {
        final String s = symbolVals.getKey();
        this.addSymbol(s);
        for (int i = 0; i < this.symbols.size(); i++) {
          if (this.symbols.get(i).equals(s)) {
            final Calendar c = (Calendar) other.getLocalTimestamp(s).clone();
            final long millis = c.getTimeInMillis();
            c.setTimeZone(other.getLocalTimestamp(s).getTimeZone());
            c.setTimeInMillis(millis);
            if (this.calendars.size() <= i) this.newTimestamp(i);
            this.calendars.set(i, c);
            break;
          }
        }
      }

      for (Map.Entry<Field, Double> fieldValue : symbolVals.getValue().entrySet()) {
        this.putValue(symbolVals.getKey(), fieldValue.getKey(), fieldValue.getValue());
      }
    }
  }
示例#2
0
 public String format(LogRecord record) {
   Calendar c = Calendar.getInstance();
   c.setTimeInMillis(record.getMillis());
   String message =
       "["
           + c.getTime().toString()
           + "]"
           + " "
           + record.getLevel()
           + ":"
           + " "
           + record.getMessage()
           + "\n";
   return message;
 }