/** * Get a string representation of this node */ public String toString() { getNodeObject(); return (namePrefix != null ? namePrefix : "") + (name!=null ? name : "") // + (type.isPrimitive() ? " = " : "") + (nodeObject!=null ? nodeObject.toString() : "null") ; }
/** * returns the object that is represented by this attribute node as is. * e.g. the field of the parent node object. * If this object is an array, the array itself is returned. If you need access to the value * of the index that is represented with this node, use getArrayValue() instead. */ protected Object getFieldValue() { try { return field.get(((ObjectInspectorNode)parent).getNodeObject()); } catch (Exception e) { //e.printStackTrace(); return "-ERROR- Exception occurred: " + e; } }
/** * Returns the value for the represented field from the parent object inspector node * If this field is an array, the value from the array index represented * by this node is returned. When access to the array is needed, e.g. to * create the the node children, use getFieldValue() instead. * @return */ protected Object getArrayValue() { try { if (isArrayNode()) { return Array.get(field.get(((ObjectInspectorNode)parent).getNodeObject()), ((ObjectInspectorNode)parent).getChildren().indexOf(this)/*-1*/); } else return "-ERROR- getArrayValue called on a non array type"; } catch (Exception e) { //e.printStackTrace(); return "-ERROR- Exception occurred: " + e; } }