Ejemplo n.º 1
0
 protected void set(String path, Object value) {
   if (path == null) {
     if (type == Type.String && value instanceof String) {
       stringValue = (String) value;
     } else if (type == Type.Integer && value instanceof Integer) {
       integerValue = (Integer) value;
     } else if (type == Type.Double && value instanceof Double) {
       doubleValue = (Double) value;
     } else if (type == Type.Record && value instanceof InformationState) {
       recordValue = (InformationState) value;
     } else if (type == Type.List && value instanceof List) {
       listValue = (List) value;
     }
   } else {
     if (type == Type.Record) {
       if (path != null) {
         recordValue.set(path, value);
       }
     } else if (type == Type.List) {
       if (path != null) {
         listValue.set(path, value);
       }
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * Prints this Item as a textual representation, with the given String put before every line.
  *
  * @param pre - the String to put in front of each line
  */
 public void print(String pre) {
   if (type == Type.String) System.out.println(stringValue);
   if (type == Type.Integer) System.out.println(integerValue);
   if (type == Type.Double) System.out.println(doubleValue);
   if (type == Type.Record) {
     System.out.println("Record\r\n" + pre + "[");
     recordValue.print(pre + "  ");
     System.out.println(pre + "]");
   }
   if (type == Type.List) {
     System.out.println(" List");
     listValue.print(pre);
   }
 }
Ejemplo n.º 3
0
  /**
   * Retrieves the value of the give path. If the path is NULL, or if the type of this Item is a
   * String, Integer, or Double it will return the value of this Item. If the path is not NULL (and
   * the type is a Record or a List), it will pass the path to the Record/List, and return the
   * resulting Item.
   *
   * @param path - the substructure-path of the item you want
   * @return the wanted Item
   */
  public Item getValueOfPath(String path) {
    if (type == Type.String) return this;
    if (type == Type.Integer) return this;
    if (type == Type.Double) return this;
    if (type == Type.Record) {
      if (path == null) {
        return this;
      } else {
        return recordValue.getValueOfPath(path);
      }
    }
    if (type == Type.List) {

      if (path == null) {
        return this;
      } else {
        return listValue.getValueOfPath(path);
      }
    }
    return null;
  }