@Test public void testTokenizer() { String[] nullFilters = NamePatternMatcher.tokenizePattern(null); assertEquals(0, nullFilters.length); String[] filters = NamePatternMatcher.tokenizePattern("billing_*,user?"); assertEquals(2, filters.length); assertEquals("^billing_.*$", filters[0]); assertEquals("^user.?$", filters[1]); }
public static String[] tokenizePattern(String pattern) { if (pattern == null || pattern.isEmpty()) { return EMPTY_ARRAY; } String[] patterns = COMMA.split(pattern); if (patterns.length == 0) { return EMPTY_ARRAY; } for (int i = 0; i < patterns.length; i++) { patterns[i] = "^" + patterns[i].replaceAll("[*?]", ".$0") + "$"; } return patterns; }
NamePatternMatcher implements NameFilter { public static String[] tokenizePattern(String pattern) { if (pattern == null || pattern.isEmpty()) { return EMPTY_ARRAY; } String[] patterns = COMMA.split(pattern); if (patterns.length == 0) { return EMPTY_ARRAY; } for (int i = 0; i < patterns.length; i++) { patterns[i] = "^" + patterns[i].replaceAll("[*?]", ".$0") + "$"; } return patterns; } }
NamePatternMatcher implements NameFilter { public static String[] tokenizePattern(String pattern) { if (pattern == null || pattern.isEmpty()) { return EMPTY_ARRAY; } String[] patterns = COMMA.split(pattern); if (patterns.length == 0) { return EMPTY_ARRAY; } for (int i = 0; i < patterns.length; i++) { patterns[i] = "^" + patterns[i].replaceAll("[*?]", ".$0") + "$"; } return patterns; } NamePatternMatcher(Pattern[] itemIncludeFilters, Pattern[] itemExcludeFilters); }
NamePatternMatcher implements NameFilter { public static String[] tokenizePattern(String pattern) { if (pattern == null || pattern.isEmpty()) { return EMPTY_ARRAY; } String[] patterns = COMMA.split(pattern); if (patterns.length == 0) { return EMPTY_ARRAY; } for (int i = 0; i < patterns.length; i++) { patterns[i] = "^" + patterns[i].replaceAll("[*?]", ".$0") + "$"; } return patterns; } NamePatternMatcher(Pattern[] itemIncludeFilters, Pattern[] itemExcludeFilters); static NamePatternMatcher build(Logger logger, String includePattern, String excludePattern); static Pattern[] createPatterns(Logger logger, String patternString); static String[] tokenizePattern(String pattern); @Override boolean isIncluded(String string); }
NamePatternMatcher implements NameFilter { public static String[] tokenizePattern(String pattern) { if (pattern == null || pattern.isEmpty()) { return EMPTY_ARRAY; } String[] patterns = COMMA.split(pattern); if (patterns.length == 0) { return EMPTY_ARRAY; } for (int i = 0; i < patterns.length; i++) { patterns[i] = "^" + patterns[i].replaceAll("[*?]", ".$0") + "$"; } return patterns; } NamePatternMatcher(Pattern[] itemIncludeFilters, Pattern[] itemExcludeFilters); static NamePatternMatcher build(Logger logger, String includePattern, String excludePattern); static Pattern[] createPatterns(Logger logger, String patternString); static String[] tokenizePattern(String pattern); @Override boolean isIncluded(String string); static final NameFilter EXCLUDE_ALL; }