FindFilter { Pattern makeNameFilter(String name) { StringBuilder sb = new StringBuilder('^'); for (char c : name.toCharArray()) { switch(c) { case '.': sb.append("\\."); break; case '*': sb.append(".*"); break; case '?': sb.append('.'); break; case '[': sb.append("\\["); break; case ']': sb.append("\\]"); break; case '(': sb.append("\\("); break; case ')': sb.append("\\)"); break; default: sb.append(c); break; } } sb.append('$'); if (debug) { System.out.println("RE=\"" + sb + "\"."); } return Pattern.compile(sb.toString()); }  void addConjunction(Find.Conjunction conj); boolean accept(Path p); String getName();  }
@Test public void testmakeNameFilter() { Pattern actual = target.makeNameFilter("Foo*.java"); Pattern expected = Pattern.compile("Foo.*\\.java$"); assertEquals("Convert Glob to Regex", expected.toString(), actual.toString()); }