private void printServerNode(int level, String serverName) { printlnAtLevel(level, "[Printing list for Server = " + serverName + "]"); String pattern = serverName + "/..."; if (level == 0) pattern = "/" + pattern; printlnAtLevel(level, "[Pattern = " + pattern + "]"); ChannelTree tr = getChannelTree(pattern); if (tr == null) { printlnAtLevel(level, "[no tree]"); return; } Iterator i = tr.rootIterator(); if (!i.hasNext()) { printlnAtLevel(level, "[empty root list]"); return; } // the first node should be for the requested serverName ChannelTree.Node node = (ChannelTree.Node) i.next(); if (!node.getType().toString().equals("Server")) { printlnAtLevel(level, "[unexpected non-Server node type = " + node.getType() + "]"); return; } if (!node.getName().equals(serverName)) { printlnAtLevel(level, "[unexpected node name = " + node.getName() + "]"); return; } printlnAtLevel( level, node.getName() + " -- " + node.getFullName() + " (" + node.getType() + ")"); printChildren(level + 1, node); }
private void exec() { connect(); ChannelTree t = getChannelTree("/..."); Iterator i = t.rootIterator(); int level = 0; if (!i.hasNext()) { printlnAtLevel(level, "[empty root list]"); } // the first node should be for the requested serverName ChannelTree.Node node = (ChannelTree.Node) i.next(); if (!node.getType().toString().equals("Server")) { printlnAtLevel(level, "[unexpected non-Server node type = " + node.getType() + "]"); return; } String serverName = node.getName(); printServerNode(level, serverName); }
private void printChildren(int level, ChannelTree.Node node) { // iterate through children of hirarchy List l = node.getChildren(); Iterator i = l.iterator(); while (i.hasNext()) { node = (ChannelTree.Node) i.next(); printlnAtLevel( level, node.getName() + " -- " + node.getFullName() + " (" + node.getType() + ")"); if (node.getType().toString().equals("Server")) printServerNode(level + 1, node.getName()); else { printChildren(level + 1, node); } } }