1 11 package org.eclipse.core.internal.watson; 12 13 import org.eclipse.core.internal.dtree.AbstractDataTreeNode; 14 import org.eclipse.core.internal.dtree.DataTreeNode; 15 16 23 class ElementSubtree { 24 protected String elementName; 25 protected Object elementData; 26 protected ElementSubtree[] children; 27 28 static final ElementSubtree[] EMPTY_ARRAY = new ElementSubtree[0]; 29 30 35 public ElementSubtree(String elementName, Object elementData, ElementSubtree[] children) { 36 if (children == null || children.length == 0) { 37 children = EMPTY_ARRAY; 38 } 39 this.elementName = elementName; 40 this.elementData = elementData; 41 this.children = children; 42 } 43 44 47 ElementSubtree(DataTreeNode childNode) { 48 AbstractDataTreeNode[] childNodes = childNode.getChildren(); 49 if (childNodes.length == 0) { 50 children = EMPTY_ARRAY; 51 } else { 52 ElementSubtree[] types = new ElementSubtree[childNodes.length]; 53 for (int i = childNodes.length; --i >= 0;) { 54 types[i] = new ElementSubtree((DataTreeNode) childNodes[i]); 55 } 56 children = types; 57 } 58 elementName = childNode.getName(); 59 elementData = childNode.getData(); 60 } 61 62 66 public ElementSubtree[] getChildren() { 67 return children; 68 } 69 70 73 public Object getElementData() { 74 return elementData; 75 } 76 77 80 public String getElementName() { 81 return elementName; 82 } 83 84 87 public String toString() { 88 return "ElementSubtree(" + elementName + ", " + elementData + ")"; } 90 } | Popular Tags |