コード例 #1
0
ファイル: Filter.java プロジェクト: smarschall/sushi
  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);
    }
  }
コード例 #2
0
ファイル: Filter.java プロジェクト: smarschall/sushi
 /**
  * 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);
 }