예제 #1
0
 /** 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();
     }
   }
 }
예제 #2
0
 /**
  * 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);
   }
 }