StringUtils { public static String patternFromGlob(String glob) { StringBuilder sb = new StringBuilder("^"); int len = glob.length(); for (int i = 0; i < len; i++) { char c = glob.charAt(i); if (c == '*') { sb.append(".*"); } else if (c == '?') { sb.append('.'); } else { if (isRegexMetaCharacter(c)) { sb.append('\\'); } sb.append(c); } } sb.append("$"); return sb.toString(); }  static boolean isRegexMetaCharacter(char regexChar); static boolean containsMatchCharacter(String name); static String patternFromGlob(String glob); static boolean containsControlCharacter(String value); static boolean requestUriMatch(String uri, Set<String> uriSet,
            List<Pattern> uriList);  }
@Test public void testPatternFromGlob() { assertEquals("^abc$", StringUtils.patternFromGlob("abc")); assertEquals("^abc.*$", StringUtils.patternFromGlob("abc*")); assertEquals("^abc.$", StringUtils.patternFromGlob("abc?")); assertEquals("^.*abc.$", StringUtils.patternFromGlob("*abc?")); assertEquals("^abc\\.abc:.*$", StringUtils.patternFromGlob("abc.abc:*")); assertEquals("^ab\\[a-c]c$", StringUtils.patternFromGlob("ab[a-c]c")); assertEquals("^ab.*\\.\\(\\)\\^\\$c$", StringUtils.patternFromGlob("ab*.()^$c")); assertEquals("^abc\\\\test\\\\$", StringUtils.patternFromGlob("abc\\test\\")); assertEquals("^ab\\{\\|c\\+$", StringUtils.patternFromGlob("ab{|c+")); assertEquals("^\\^\\$\\[\\(\\)\\\\\\+\\{\\..*.\\|$", StringUtils.patternFromGlob("^$[()\\+{.*?|")); }