/** * Determine if the current entry is a parent, a match, or no match. * <p> * This method extends the result returned by {@link #include(TreeWalk)} * with a third option (-1), splitting the value true. This gives the * application a possibility to distinguish between an exact match and the * case when a subtree to the current entry might be a match. * * @param walker * the walker the filter needs to examine. * @return -1 if the current entry is a parent of the filter but no exact * match has been made; 0 if the current entry should be seen by the * application; 1 if it should be hidden. * @throws org.eclipse.jgit.errors.MissingObjectException * as thrown by {@link #include(TreeWalk)} * @throws org.eclipse.jgit.errors.IncorrectObjectTypeException * as thrown by {@link #include(TreeWalk)} * @throws java.io.IOException * as thrown by {@link #include(TreeWalk)} * @since 4.7 */ public int matchFilter(TreeWalk walker) throws MissingObjectException, IncorrectObjectTypeException, IOException { return include(walker) ? 0 : 1; }
@Override public boolean shouldBeRecursive() { for (TreeFilter f : subfilters) if (f.shouldBeRecursive()) return true; return false; }
@Override public int matchFilter(TreeWalk walker) throws MissingObjectException, IncorrectObjectTypeException, IOException { int m = 1; for (TreeFilter f : subfilters) { int r = f.matchFilter(walker); if (r == 0) { return 0; } if (r == -1) { m = -1; } } return m; }
/** {@inheritDoc} */ @Override public int matchFilter(TreeWalk walker) throws MissingObjectException, IncorrectObjectTypeException, IOException { final int r = a.matchFilter(walker); // switch 0 and 1, keep -1 as that defines a subpath that must be // traversed before a final verdict can be made. if (r == 0) { return 1; } if (r == 1) { return 0; } return -1; }
if (filter != null) { try { boolean marked = filter.include(walk); if (marked) marks |= (1L << index);
/** {@inheritDoc} */ @Override public boolean shouldBeRecursive() { return a.shouldBeRecursive(); }
/** {@inheritDoc} */ @Override public String toString() { return "NOT " + a.toString(); //$NON-NLS-1$ } }
/** {@inheritDoc} */ @Override public TreeFilter clone() { final TreeFilter n = a.clone(); return n == a ? this : new NotTreeFilter(n); }
@Override public int matchFilter(TreeWalk walker) throws MissingObjectException, IncorrectObjectTypeException, IOException { int m = 0; for (TreeFilter f : subfilters) { int r = f.matchFilter(walker); if (r == 1) { return 1; } if (r == -1) { m = -1; } } return m; }
/** {@inheritDoc} */ @Override public boolean include(TreeWalk walker) throws MissingObjectException, IncorrectObjectTypeException, IOException { return path.include(walker) && ANY_DIFF.include(walker); }
@Override public boolean shouldBeRecursive() { for (TreeFilter f : subfilters) if (f.shouldBeRecursive()) return true; return false; }
@Override public TreeFilter clone() { final TreeFilter[] s = new TreeFilter[subfilters.length]; for (int i = 0; i < s.length; i++) s[i] = subfilters[i].clone(); return new List(s); }
@Override public int matchFilter(TreeWalk walker) throws MissingObjectException, IncorrectObjectTypeException, IOException { final int ra = a.matchFilter(walker); if (ra == 0) { return 0; } final int rb = b.matchFilter(walker); if (rb == 0) { return 0; } if (ra == -1 || rb == -1) { return -1; } return 1; }
@Override public boolean shouldBeRecursive() { return a.shouldBeRecursive() || b.shouldBeRecursive(); }
@Override public String toString() { final StringBuilder r = new StringBuilder(); r.append("("); //$NON-NLS-1$ for (int i = 0; i < subfilters.length; i++) { if (i > 0) r.append(" OR "); //$NON-NLS-1$ r.append(subfilters[i].toString()); } r.append(")"); //$NON-NLS-1$ return r.toString(); } }