@Override public boolean matches(final String className) { return FilenameUtils.wildcardMatch(className, pattern); } }
/** * Checks to see if the filename matches one of the wildcards. * * @param dir the file directory (ignored) * @param name the filename * @return true if the filename matches one of the wildcards */ @Override public boolean accept(final File dir, final String name) { for (final String wildcard : wildcards) { if (FilenameUtils.wildcardMatch(name, wildcard, caseSensitivity)) { return true; } } return false; }
/** * Checks a filename to see if it matches the specified wildcard matcher * using the case rules of the system. * <p> * The wildcard matcher uses the characters '?' and '*' to represent a * single or multiple (zero or more) wildcard characters. * This is the same as often found on Dos/Unix command lines. * The check is case-sensitive on Unix and case-insensitive on Windows. * <pre> * wildcardMatch("c.txt", "*.txt") --> true * wildcardMatch("c.txt", "*.jpg") --> false * wildcardMatch("a/b/c.txt", "a/b/*") --> true * wildcardMatch("c.txt", "*.???") --> true * wildcardMatch("c.txt", "*.????") --> false * </pre> * N.B. the sequence "*?" does not work properly at present in match strings. * * @param filename the filename to match on * @param wildcardMatcher the wildcard string to match against * @return true if the filename matches the wildcard string * @see IOCase#SYSTEM */ public static boolean wildcardMatchOnSystem(final String filename, final String wildcardMatcher) { return wildcardMatch(filename, wildcardMatcher, IOCase.SYSTEM); }
/** * Checks a filename to see if it matches the specified wildcard matcher, * always testing case-sensitive. * <p> * The wildcard matcher uses the characters '?' and '*' to represent a * single or multiple (zero or more) wildcard characters. * This is the same as often found on Dos/Unix command lines. * The check is case-sensitive always. * <pre> * wildcardMatch("c.txt", "*.txt") --> true * wildcardMatch("c.txt", "*.jpg") --> false * wildcardMatch("a/b/c.txt", "a/b/*") --> true * wildcardMatch("c.txt", "*.???") --> true * wildcardMatch("c.txt", "*.????") --> false * </pre> * N.B. the sequence "*?" does not work properly at present in match strings. * * @param filename the filename to match on * @param wildcardMatcher the wildcard string to match against * @return true if the filename matches the wildcard string * @see IOCase#SENSITIVE */ public static boolean wildcardMatch(final String filename, final String wildcardMatcher) { return wildcardMatch(filename, wildcardMatcher, IOCase.SENSITIVE); }
/** * Checks to see if the filename matches one of the wildcards. * * @param file the file to check * @return true if the filename matches one of the wildcards */ @Override public boolean accept(final File file) { final String name = file.getName(); for (final String wildcard : wildcards) { if (FilenameUtils.wildcardMatch(name, wildcard, caseSensitivity)) { return true; } } return false; }
/** * Checks to see if the filename matches one of the wildcards. * * @param dir the file directory * @param name the filename * @return true if the filename matches one of the wildcards */ public boolean accept(File dir, String name) { for (int i = 0; i < wildcards.length; i++) { if (FilenameUtils.wildcardMatch(name, wildcards[i], caseSensitivity)) { return true; } } return false; }
/** * Checks to see if the filename matches one of the wildcards. * * @param file the file to check * @return true if the filename matches one of the wildcards */ @Override public boolean accept(final File file) { if (file.isDirectory()) { return false; } for (final String wildcard : wildcards) { if (FilenameUtils.wildcardMatch(file.getName(), wildcard)) { return true; } } return false; }
/** * Checks to see if the filename matches one of the wildcards. * * @param dir the file directory * @param name the filename * @return true if the filename matches one of the wildcards */ @Override public boolean accept(final File dir, final String name) { if (dir != null && new File(dir, name).isDirectory()) { return false; } for (final String wildcard : wildcards) { if (FilenameUtils.wildcardMatch(name, wildcard)) { return true; } } return false; }
/** * Checks a filename to see if it matches the specified wildcard matcher * using the case rules of the system. * <p> * The wildcard matcher uses the characters '?' and '*' to represent a * single or multiple wildcard characters. * This is the same as often found on Dos/Unix command lines. * The check is case-sensitive on Unix and case-insensitive on Windows. * <pre> * wildcardMatch("c.txt", "*.txt") --> true * wildcardMatch("c.txt", "*.jpg") --> false * wildcardMatch("a/b/c.txt", "a/b/*") --> true * wildcardMatch("c.txt", "*.???") --> true * wildcardMatch("c.txt", "*.????") --> false * </pre> * * @param filename the filename to match on * @param wildcardMatcher the wildcard string to match against * @return true if the filename matches the wilcard string * @see IOCase#SYSTEM */ public static boolean wildcardMatchOnSystem(String filename, String wildcardMatcher) { return wildcardMatch(filename, wildcardMatcher, IOCase.SYSTEM); }
/** * Checks a filename to see if it matches the specified wildcard matcher, * always testing case-sensitive. * <p> * The wildcard matcher uses the characters '?' and '*' to represent a * single or multiple wildcard characters. * This is the same as often found on Dos/Unix command lines. * The check is case-sensitive always. * <pre> * wildcardMatch("c.txt", "*.txt") --> true * wildcardMatch("c.txt", "*.jpg") --> false * wildcardMatch("a/b/c.txt", "a/b/*") --> true * wildcardMatch("c.txt", "*.???") --> true * wildcardMatch("c.txt", "*.????") --> false * </pre> * * @param filename the filename to match on * @param wildcardMatcher the wildcard string to match against * @return true if the filename matches the wilcard string * @see IOCase#SENSITIVE */ public static boolean wildcardMatch(String filename, String wildcardMatcher) { return wildcardMatch(filename, wildcardMatcher, IOCase.SENSITIVE); }
/** * Checks to see if the filename matches one of the wildcards. * * @param file the file to check * @return true if the filename matches one of the wildcards */ public boolean accept(File file) { String name = file.getName(); for (int i = 0; i < wildcards.length; i++) { if (FilenameUtils.wildcardMatch(name, wildcards[i], caseSensitivity)) { return true; } } return false; }
/** * Checks to see if the filename matches one of the wildcards. * * @param dir the file directory * @param name the filename * @return true if the filename matches one of the wildcards */ public boolean accept(File dir, String name) { if (dir != null && new File(dir, name).isDirectory()) { return false; } for (int i = 0; i < wildcards.length; i++) { if (FilenameUtils.wildcardMatch(name, wildcards[i])) { return true; } } return false; }
/** * Checks to see if the filename matches one of the wildcards. * * @param file the file to check * @return true if the filename matches one of the wildcards */ public boolean accept(File file) { if (file.isDirectory()) { return false; } for (int i = 0; i < wildcards.length; i++) { if (FilenameUtils.wildcardMatch(file.getName(), wildcards[i])) { return true; } } return false; }
private void assertMatch(final String text, final String wildcard, final boolean expected) { assertEquals(text + " " + wildcard, expected, FilenameUtils.wildcardMatch(text, wildcard)); }
if (FilenameUtils.wildcardMatch( Path.getPathWithoutSchemeAndAuthority(coprocPath).toString(), Path.getPathWithoutSchemeAndAuthority(wlPath).toString())) {
@Test public void testMatch() { assertFalse(FilenameUtils.wildcardMatch(null, "Foo")); assertFalse(FilenameUtils.wildcardMatch("Foo", null)); assertTrue(FilenameUtils.wildcardMatch(null, null)); assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo")); assertTrue(FilenameUtils.wildcardMatch("", "")); assertTrue(FilenameUtils.wildcardMatch("", "*")); assertFalse(FilenameUtils.wildcardMatch("", "?")); assertTrue(FilenameUtils.wildcardMatch("Foo", "Fo*")); assertTrue(FilenameUtils.wildcardMatch("Foo", "Fo?")); assertTrue(FilenameUtils.wildcardMatch("Foo Bar and Catflap", "Fo*")); assertTrue(FilenameUtils.wildcardMatch("New Bookmarks", "N?w ?o?k??r?s")); assertFalse(FilenameUtils.wildcardMatch("Foo", "Bar")); assertTrue(FilenameUtils.wildcardMatch("Foo Bar Foo", "F*o Bar*")); assertTrue(FilenameUtils.wildcardMatch("Adobe Acrobat Installer", "Ad*er")); assertTrue(FilenameUtils.wildcardMatch("Foo", "*Foo")); assertTrue(FilenameUtils.wildcardMatch("BarFoo", "*Foo")); assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo*")); assertTrue(FilenameUtils.wildcardMatch("FooBar", "Foo*")); assertFalse(FilenameUtils.wildcardMatch("FOO", "*Foo")); assertFalse(FilenameUtils.wildcardMatch("BARFOO", "*Foo")); assertFalse(FilenameUtils.wildcardMatch("FOO", "Foo*")); assertFalse(FilenameUtils.wildcardMatch("FOOBAR", "Foo*")); }
@Test public void testMatchCaseSpecified() { assertFalse(FilenameUtils.wildcardMatch(null, "Foo", IOCase.SENSITIVE)); assertFalse(FilenameUtils.wildcardMatch("Foo", null, IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch(null, null, IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("", "", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Foo", "Fo*", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Foo", "Fo?", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Foo Bar and Catflap", "Fo*", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("New Bookmarks", "N?w ?o?k??r?s", IOCase.SENSITIVE)); assertFalse(FilenameUtils.wildcardMatch("Foo", "Bar", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Foo Bar Foo", "F*o Bar*", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Adobe Acrobat Installer", "Ad*er", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Foo", "*Foo", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo*", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Foo", "*Foo", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("BarFoo", "*Foo", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo*", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("FooBar", "Foo*", IOCase.SENSITIVE)); assertFalse(FilenameUtils.wildcardMatch("FOO", "*Foo", IOCase.SENSITIVE)); assertFalse(FilenameUtils.wildcardMatch("BARFOO", "*Foo", IOCase.SENSITIVE)); assertFalse(FilenameUtils.wildcardMatch("FOO", "Foo*", IOCase.SENSITIVE)); assertFalse(FilenameUtils.wildcardMatch("FOOBAR", "Foo*", IOCase.SENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("FOO", "*Foo", IOCase.INSENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("BARFOO", "*Foo", IOCase.INSENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("FOO", "Foo*", IOCase.INSENSITIVE)); assertTrue(FilenameUtils.wildcardMatch("FOOBAR", "Foo*", IOCase.INSENSITIVE)); assertEquals(WINDOWS, FilenameUtils.wildcardMatch("FOO", "*Foo", IOCase.SYSTEM));
@Test public void testLocaleIndependence() { final Locale orig = Locale.getDefault(); final Locale[] locales = Locale.getAvailableLocales(); final String[][] data = { { "I", "i"}, { "i", "I"}, { "i", "\u0130"}, { "i", "\u0131"}, { "\u03A3", "\u03C2"}, { "\u03A3", "\u03C3"}, { "\u03C2", "\u03C3"}, }; try { for (int i = 0; i < data.length; i++) { for (final Locale locale : locales) { Locale.setDefault(locale); assertTrue("Test data corrupt: " + i, data[i][0].equalsIgnoreCase(data[i][1])); final boolean match = FilenameUtils.wildcardMatch(data[i][0], data[i][1], IOCase.INSENSITIVE); assertTrue(Locale.getDefault().toString() + ": " + i, match); } } } finally { Locale.setDefault(orig); } }
if (FilenameUtils.wildcardMatch(contentType.toLowerCase(), accept)) { accepted = true; if (LOGGER.isLoggable(Level.FINE)) {
/** * @param filename * @return true if the input filename is of this {@link FileType} */ public boolean matches(String filename) { for (String current : getFilter().getExtensions()) { if (wildcardMatch(filename, current, IOCase.INSENSITIVE)) { return true; } } return false; } }