/** * Creates pattern with specified separator for directories. * <p> * This is used to match Java-classes, i.e. <code>org.foo.Bar</code> against <code>org/**</code>. * <b>However usage of character other than "/" as a directory separator is misleading and should be avoided, * so method {@link #create(String)} is preferred over this one.</b> * * <p> * Also note that no matter whether forward or backward slashes were used in the <code>antPattern</code> * the returned pattern will use <code>directorySeparator</code>. * Thus to match Windows-style path "dir\file.ext" against pattern "dir/file.ext" normalization should be performed. * */ public static WildcardPattern create(String pattern, String directorySeparator) { String key = pattern + directorySeparator; return CACHE.computeIfAbsent(key, k -> new WildcardPattern(pattern, directorySeparator)); } }
private boolean match(String pattern, String value) { return new WildcardPattern(pattern, "/").match(value); }
private boolean match(String pattern, String value, String separator) { return new WildcardPattern(pattern, separator).match(value); }
/** * Creates pattern with specified separator for directories. * <p> * This is used to match Java-classes, i.e. <code>org.foo.Bar</code> against <code>org/**</code>. * <b>However usage of character other than "/" as a directory separator is misleading and should be avoided, * so method {@link #create(String)} is preferred over this one.</b> * * <p> * Also note that no matter whether forward or backward slashes were used in the <code>antPattern</code> * the returned pattern will use <code>directorySeparator</code>. * Thus to match Windows-style path "dir\file.ext" against pattern "dir/file.ext" normalization should be performed. * */ public static WildcardPattern create(String pattern, String directorySeparator) { String key = pattern + directorySeparator; return CACHE.computeIfAbsent(key, k -> new WildcardPattern(pattern, directorySeparator)); } }
/** * Creates pattern with specified separator for directories. * <p> * This is used to match Java-classes, i.e. <code>org.foo.Bar</code> against <code>org/**</code>. * <b>However usage of character other than "/" as a directory separator is misleading and should be avoided, * so method {@link #create(String)} is preferred over this one.</b> * </p> * <p> * Also note that no matter whether forward or backward slashes were used in the <code>antPattern</code> * the returned pattern will use <code>directorySeparator</code>. * Thus to match Windows-style path "dir\file.ext" against pattern "dir/file.ext" normalization should be performed. * </p> */ public static WildcardPattern create(String pattern, String directorySeparator) { String key = pattern + directorySeparator; WildcardPattern wildcardPattern = CACHE.get(key); if (wildcardPattern == null) { wildcardPattern = new WildcardPattern(pattern, directorySeparator); CACHE.put(key, wildcardPattern); } return wildcardPattern; } }