Пример #1
0
  private void marchTree(List<PermissibleObject> comments, PermissibleObjectTreeNode node) {
    if (node.getObject() != null) {
      comments.add(node.getObject());
    }

    // let's sort the children so the list makes sense
    List<PermissibleObject> permissibleObjects =
        new ArrayList<PermissibleObject>(node.getChildren().keySet());
    Collections.sort(permissibleObjects);

    for (PermissibleObject object : permissibleObjects) {
      marchTree(comments, node.getChildren().get(object));
    }
  }
Пример #2
0
 private PermissibleObjectTreeNode findParentCommentNode(
     PermissibleObjectTreeNode rootNode, PermissibleObjectTreeNode node) {
   if (node.getObject().equals(rootNode.getObject())) {
     return rootNode;
   }
   for (PermissibleObject obj : rootNode.getChildren().keySet()) {
     if (obj.equals(((Comment) node.getObject()).getParentComment())) {
       return rootNode.getChildren().get(obj);
     }
     PermissibleObjectTreeNode possibleParent =
         findParentCommentNode(rootNode.getChildren().get(obj), node);
     if (possibleParent != null) {
       return possibleParent;
     }
   }
   return null;
 }