/** Traverse a path from a parent node down, by an enumeration of names. * @param start node to start searching at * @param names enumeration of names of nodes * along the path * @return the node with such a path from the start node * @exception NodeNotFoundException if the node with such name * does not exists; the exception contains additional information * about the failure. */ public static Node findPath(Node start, Enumeration<String> names) throws NodeNotFoundException { int depth = 0; while (names.hasMoreElements()) { String name = names.nextElement(); Node next = findChild(start, name); if (next == null) { // no element in list matched the name => fail // fire exception with the last accessed node and the // name of child that does not exists throw new NodeNotFoundException(start, name, depth); } else { // go on next node start = next; } // continue on next depth depth++; } return start; }
Node next = findChild (start, name); if (next == null) {
Node next = findChild (start, name); if (next == null) {
private Node findNodeInServerFiles(Node root, FileObject fo) { Node configFiles = root.getChildren().findChild("setup"); // NOI18N if (configFiles == null) { return null; } return NodeOp.findChild(configFiles, fo.getName()); }
private Node findNode(Node pnode, String name) { // First try all children of this node Node node = NodeOp.findChild(pnode, name); if (node != null) { return node; } // Then try it's children Children ch = pnode.getChildren(); Node nodes[] = ch.getNodes(true); for (int i = 0; i < nodes.length; i++) { Node cnode = findNode(nodes[i], name); if (cnode != null) { return cnode; } } return null; }
private Node findNodeInConfigFiles(Node root, FileObject fo) { // XXX ugly, some node names contain the extension and other don't // so retrieving the node name from the corresp. DataObject String nodeName; try { DataObject dobj = DataObject.find(fo); nodeName = dobj.getName(); } catch (DataObjectNotFoundException e) { nodeName = fo.getName(); } Node configFiles = root.getChildren().findChild("configurationFiles"); // NOI18N if (configFiles == null) { return null; } return NodeOp.findChild(configFiles, nodeName); }