/** * Applies child expressions to the {@link PathData} item. If all pass then * returns {@link Result#PASS} else returns the result of the first * non-passing expression. */ @Override public Result apply(PathData item, int depth) throws IOException { Result result = Result.PASS; for (Expression child : getChildren()) { Result childResult = child.apply(item, -1); result = result.combine(childResult); if (!result.isPass()) { return result; } } return result; }
private void applyItem(PathData item) throws IOException { if (getDepth() >= getOptions().getMinDepth()) { Result result = getRootExpression().apply(item, getDepth()); if (Result.STOP.equals(result)) { addStop(item); } } }
@Test public void equalsFail() { Result one = Result.FAIL; Result two = Result.FAIL.combine(Result.FAIL); assertEquals(one, two); }
/** {@inheritDoc} */ @Override public Result apply(PathData item) throws IOException { for(Expression child : getChildren()) { Result result = child.apply(item); if(result.isPass()) { return result; } } return Result.FAIL; }
/** {@inheritDoc} */ @Override protected void processPaths(PathData parent, PathData ... items) throws IOException { if(parent == null) { // processing a command line argument so clear the links followed linksFollowed.clear(); } Expression expr = getRootExpression(); for (PathData item : items) { try { if(getOptions().isDepth()) { recursePath(item); expr.apply(item); } else if (expr.apply(item).isDescend()) { recursePath(item); } } catch (IOException e) { displayError(e); } } }
/** {@inheritDoc} */ @Override public Result apply(PathData item) throws IOException { Expression child = getChildren().get(0); Result result = child.apply(item); return result.negate(); }
@Test public void equalsFail() { Result one = Result.FAIL; Result two = Result.FAIL.combine(Result.FAIL); assertEquals(one, two); }
@Test public void equalsStop() { Result one = Result.STOP; Result two = Result.STOP.combine(Result.STOP); assertEquals(one, two); }