Exemple #1
0
 /**
  * Stores the value for the given field associated to last inserted symbol. If no symbol has been
  * inserted yet, an exception occurs.
  */
 public void putValue(final Field field, final double val) {
   final String symbol = symbols.get(symbols.size() - 1);
   Map<Field, Double> vs = values.get(symbol);
   if (vs == null) vs = new HashMap<Field, Double>();
   vs.put(field, val);
   this.values.put(symbol, vs);
 }
Exemple #2
0
  /**
   * Stores the value for the given field associated to given symbol. Be careful: If symbol has not
   * been previously inserted, object will become incoherent.
   */
  public void putValue(final String symbol, final Field field, final double val) {
    Map<Field, Double> vs = values.get(symbol);
    if (vs == null) vs = new HashMap<Field, Double>();
    vs.put(field, val);
    this.values.put(symbol, vs);

    // Consistency check.
    for (int i = 0; i < this.symbols.size(); i++) {
      if (this.symbols.get(i).equals(symbol)) return;
    }
    log.severe(
        "Danger: inconsistent usage of ParseResult object. "
            + "'putValue' function should be called AFTER 'addSymbol'. "
            + "Read documentation");
  }
Exemple #3
0
  /** Clones result COPYING all data into new variables. */
  public Object clone() {
    final ParseResult cloned = new ParseResult();

    for (int i = 0; i < this.symbols.size(); i++) {
      cloned.symbols.add(this.symbols.get(i));
    }

    for (final Map.Entry<String, Map<Field, Double>> entry1 : this.values.entrySet()) {
      final Map<Field, Double> vals = new HashMap<Field, Double>();
      for (final Map.Entry<Field, Double> entry2 : entry1.getValue().entrySet()) {
        vals.put(entry2.getKey(), entry2.getValue());
      }
      cloned.values.put(entry1.getKey(), vals);
    }

    for (final Calendar c : this.calendars) {
      cloned.calendars.add((Calendar) c.clone());
    }

    return cloned;
  }