use of org.eclipse.wst.dtd.core.internal.NodeList in project webtools.sourceediting by eclipse.
the class DTDTreeContentProvider method getChildren.
public Object[] getChildren(Object parentElement) {
// otherwise
if (parentElement instanceof DTDFile) {
if (isShowLogicalOrder()) {
// return the visible node lists
if (logicalNodeLists == null) {
Iterator nodeLists = ((DTDFile) parentElement).getNodeLists().iterator();
List visibleLists = new ArrayList(7);
while (nodeLists.hasNext()) {
NodeList list = (NodeList) nodeLists.next();
if (isVisibleNodeList(list)) {
visibleLists.add(list);
}
}
logicalNodeLists = visibleLists.toArray();
}
return logicalNodeLists;
} else {
// return the visible nodes
List allNodes = ((DTDFile) parentElement).getNodes();
List visibleNodes = new ArrayList(allNodes.size());
for (int i = 0; i < allNodes.size(); i++) {
Object o = allNodes.get(i);
if (isVisibleNode(o)) {
visibleNodes.add(o);
}
}
return visibleNodes.toArray();
}
} else if (parentElement instanceof NodeList) {
return ((NodeList) parentElement).getNodes().toArray();
} else if (parentElement instanceof Element) {
// always group the attributes directly under the element
Object[] children = ((DTDNode) parentElement).getChildren();
List attributes = ((Element) parentElement).getElementAttributes();
Object[] logicalChildren = new Object[children.length + attributes.size()];
int index = 0;
for (index = 0; index < children.length; index++) {
logicalChildren[index] = children[index];
}
for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
logicalChildren[index++] = iter.next();
}
return logicalChildren;
} else if (parentElement instanceof DTDNode) {
return ((DTDNode) parentElement).getChildren();
}
return Collections.EMPTY_LIST.toArray();
}
Aggregations