Exemplo n.º 1
0
  public TreeNode[] findNodeInContext(String startCtxPath, @Nullable final String name) {
    final List<TreeNode> out = new ArrayList<TreeNode>();
    root.iterateThruContext(
        startCtxPath,
        new TreeNodeRoot.TreeNodeHandler2() {
          public boolean handleNode(int ctxPathCounter, TreeNode node) {
            if (name == null || node.getName().equalsIgnoreCase(name)) {
              out.add(node);
            }
            return true;
          }
        });

    return out.toArray(new TreeNode[out.size()]);
    /*
            String[] path = startCtxPath.split("/");
            int startWith = ("/" + path[1]).startsWith(ContextPath.FILE_CTX_PRX) ? 2 : 1;

            TreeNode cycled = root;
            for (int i = startWith; i < path.length; i++) {
                String encodedName = "/" + path[i];
                cycled = cycled.findChildByEncodedName(encodedName);
                if (cycled == null) {
                    return new TreeNode[0];
                }
            }

            return cycled.findChildrenBySuffix(name);
    */
  }
Exemplo n.º 2
0
  public TreeNode[] findNodeInContext(final String ctxPath, final int[] ctxTypes) {
    //        final List<Integer>  types = primitiveArrayToObjectList(ctxTypes);
    final List<TreeNode> out = new ArrayList<TreeNode>();
    root.iterateThruContext(
        ctxPath,
        new TreeNodeRoot.TreeNodeHandler2() {
          public boolean handleNode(int ctxPathCounter, TreeNode node) {
            if (node.getPath().equals(ctxPath)) {
              out.addAll(Arrays.asList(node.findChildrenByTypes(ctxTypes)));
              return false;
            }
            //                if(types.size() == 0 || types.contains(node.getType())){
            //                    out.add(node);
            //                }
            return true;
          }
        });

    return out.toArray(new TreeNode[out.size()]);
  }