001package daikon.chicory;
002
003/**
004 * The ArrayInfo class is a subtype of DaikonVariableInfo used for variable types that are arrays
005 * (i.e., their name ends with "[]").
006 */
007public class ArrayInfo extends DaikonVariableInfo {
008  /** Component type of the array. */
009  Class<?> array_type;
010
011  /**
012   * Constructs an ArrayInfo object with the specified name and type.
013   *
014   * @param theName the variable name. Should end with "[]".
015   * @param array_type component type of the array
016   */
017  public ArrayInfo(String theName, Class<?> array_type) {
018
019    super(theName, array_type.getName() + "[]", getRepName(array_type, true) + "[]", true);
020    this.array_type = array_type;
021  }
022
023  @Override
024  public Object getMyValFromParentVal(Object value) {
025    if (value == null) {
026      return NonsensicalList.getInstance();
027    } else if (value instanceof NonsensicalObject) {
028      return NonsensicalList.getInstance();
029    } else {
030      // The "child" value of an array is the actual list of array values
031      // as opposed to just the "hashcode" object.
032      return DTraceWriter.getListFromArray(value);
033    }
034  }
035
036  public Class<?> getType() {
037    return array_type;
038  }
039
040  @Override
041  public VarKind get_var_kind() {
042    return VarKind.ARRAY;
043  }
044}