/** Remove empty subgroups from the subtree. */ public void removeEmptySubgroups() { if (type != GROUP) { return; } for (Iterator i = children.iterator(); i.hasNext(); ) { HierarchyNode n = (HierarchyNode) i.next(); n.removeEmptySubgroups(); if (n.getType() == GROUP && n.getChildren().isEmpty()) { i.remove(); } } }
/** * Add a child to list of children * * @param child the child nod to be added * @throws DataSourceException */ public void addChild(HierarchyNode child) throws DataSourceException { if (type == ELEMENT) { throw new DataSourceException( Errors.CANT_ADD_CHILD_TO_ELEMENT, new Object[] {label, child.getLabel()}); } // add only once if (!children.contains(child)) { children.add(child); } }