/** * Get the given child of a node. */ public Object getChild(Object parent, int index) { // System.out.println("getChild: "+parent+", "+index); Object ret; // Node for an ObjectInspector object. if(parent instanceof ObjectInspectorNode) { ret = ((ObjectInspectorNode)parent).getChildren().get(index); } // Node for an ObjectAttributeInspector object. else if(parent instanceof ObjectInspectorAttributeNode) { ret = ((ObjectInspectorAttributeNode)parent).getChildren().get(index); } // Value node has no children. else { throw new IllegalArgumentException("Node has no children: "+parent); } return ret; }
/** * Get the number of children of the given node. */ public int getChildCount(Object parent) { // System.out.println("getChildCount: "+parent); int count; // Node for an ObjectInspector object. if(parent instanceof ObjectInspectorNode) { count = ((ObjectInspectorNode)parent).getChildren().size(); } // Node for an ObjectAttributeInspector object. else if(parent instanceof ObjectInspectorAttributeNode) { count = ((ObjectInspectorAttributeNode)parent).getChildren().size(); } // Node is value. else { count = 0; } return count; }
List newchildren = node.getChildren(); node.children = oldchildren;