Beispiel #1
0
  private void doInvoke(
      int currentDepth,
      Node parent,
      boolean parentIsLink,
      List<Object[]> includes,
      List<Object[]> excludes,
      Action result)
      throws IOException {
    List<? extends Node> children;
    List<Object[]> remainingIncludes;
    List<Object[]> remainingExcludes;
    String name;
    boolean childIsLink;
    boolean in;
    boolean ex;

    if (currentDepth >= maxDepth) {
      return;
    }
    if (!followLinks && parentIsLink) {
      return;
    }
    try {
      children = list(parent, includes);
    } catch (IOException e) {
      result.enterFailed(parent, parentIsLink, e);
      return;
    }
    if (children == null) {
      // ignore file
    } else {
      result.enter(parent, parentIsLink);
      currentDepth++;
      for (Node child : children) {
        name = child.getName();
        childIsLink = child.isLink();
        remainingIncludes = new ArrayList<>();
        remainingExcludes = new ArrayList<>();
        in = doMatch(name, includes, remainingIncludes);
        ex = doMatch(name, excludes, remainingExcludes);
        if (in && !ex && currentDepth >= minDepth && matchPredicates(child, childIsLink)) {
          result.select(child, childIsLink);
        }
        if (remainingIncludes.size() > 0 && !excludesAll(remainingExcludes)) {
          doInvoke(currentDepth, child, childIsLink, remainingIncludes, remainingExcludes, result);
        }
      }
      result.leave(parent, parentIsLink);
    }
  }
Beispiel #2
0
 /**
  * Main methods of this class.
  *
  * @throws IOException as thrown by the specified FileTask
  */
 public void invoke(Node root, Action result) throws IOException {
   doInvoke(0, root, root.isLink(), new ArrayList<>(includes), new ArrayList<>(excludes), result);
 }