@Test public void testFilterExclude() throws Exception { FileFilterRule nameEndsWithDotTxt = new FileNameFileFilterRule(new TextValue(".txt"), FileNameFileFilterRule.OP_ENDS_WITH); FileFilterRule sizeIsLessThan1k = new FileSizeFileFilterRule(new SizeValue("1024 Bytes"), FileSizeFileFilterRule.OP_IS_LESS_THAN); FileFilter filter = new FileFilter(FileFilter.MATCH_ANY, FileFilter.EXCLUDE, true, nameEndsWithDotTxt, sizeIsLessThan1k); assertFalse(filter.match(new TestNode("foobar.txt", root, true, false, 0, 0))); assertFalse(filter.match(new TestNode("foobar.txt.", root, true, false, 0, 0))); assertTrue(filter.match(new TestNode("foobar.txt.", root, true, false, 2048, 0))); }
public boolean match(final File file) { boolean result = doMmatch(file); return filterType == INCLUDE ? result : !result; }
FileFilter { public boolean match(final File file) { boolean result = doMmatch(file); return filterType == INCLUDE ? result : !result; } }
FileFilter { public boolean match(final File file) { boolean result = doMmatch(file); return filterType == INCLUDE ? result : !result; } FileFilter(int matchType, int filterType, boolean appliesToDir, FileFilterRule... rules); }
FileFilter { public boolean match(final File file) { boolean result = doMmatch(file); return filterType == INCLUDE ? result : !result; } FileFilter(int matchType, int filterType, boolean appliesToDir, FileFilterRule... rules); int getMatchType(); int getFilterType(); boolean appliesToDirectories(); FileFilterRule[] getFileFiltersRules(); boolean match(final File file); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
FileFilter { public boolean match(final File file) { boolean result = doMmatch(file); return filterType == INCLUDE ? result : !result; } FileFilter(int matchType, int filterType, boolean appliesToDir, FileFilterRule... rules); int getMatchType(); int getFilterType(); boolean appliesToDirectories(); FileFilterRule[] getFileFiltersRules(); boolean match(final File file); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final int MATCH_ALL; static final int MATCH_ANY; static final int INCLUDE; static final int EXCLUDE; }