/** * get the children of this group in the tree (recursive call) * * @param root of the tree * @return a list of the children of the group or null if no children (to be initialized by * caller) */ public ArrayList<PDLGroup> getChildren(DefaultMutableTreeNode root, ArrayList<PDLGroup> list) { PDLGroup rootGroup = (PDLGroup) root.getUserObject(); String rootGroupName = rootGroup.getName(); if (this.name.equals(rootGroupName)) { @SuppressWarnings("rawtypes") Enumeration children = root.children(); while (children.hasMoreElements()) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); list.add((PDLGroup) child.getUserObject()); } return list; } else { @SuppressWarnings("rawtypes") Enumeration children = root.children(); if (children != null) { while (children.hasMoreElements()) { ArrayList<PDLGroup> l = getChildren((DefaultMutableTreeNode) children.nextElement(), list); if (l != null) return l; } } } return null; }
// unit test public static void main(String[] args) { try { PDLGroup newGroup = new PDLGroup("TestGroup"); newGroup.addPDLParam("TestParam"); newGroup.removePDLParam("TestParam"); } catch (Exception e) { e.printStackTrace(); } }