@Test public void testMatches() throws ParseException { assertTrue(PathElement.pathElement("{path}").matches("foo")); assertTrue(PathElement.pathElement("{path}bar").matches("foo-foobar")); assertTrue(PathElement.pathElement("{path: .*}").matches("foo/bar")); assertTrue(PathElement.pathElement("{path: .*}/bar").matches("foo/foo-bar/bar")); assertFalse(PathElement.pathElement("{path: .*}/bar").matches("foo/foo-bar/")); assertTrue(PathElement.pathElement("{alphapath: [a-zA-Z]{3}}/{numpath: [0-9]*}").matches("foo/123")); assertFalse(PathElement.pathElement("{alphapath: [a-zA-Z]{3}}/{numpath: [0-9]*}").matches("foobar/123")); assertFalse(PathElement.pathElement("{alphapath: [a-zA-Z]{3}}/{numpath: [0-9]*}").matches("foo/a123")); assertTrue(PathElement.pathElement("{weird: \\{foo\\}\\/\\{bar\\}}").matches("{foo}/{bar}")); assertFalse(PathElement.pathElement("{weird: \\{foo\\}\\/\\{bar\\}}").matches("foo/bar")); assertTrue(PathElement.pathElement("foo/{required}/{optional: .*}").matches("foo/bar/")); assertFalse(PathElement.pathElement("foo/{bar}/{required}").matches("foo/bar")); }
public boolean matches(String path) { int start = 0; if (path.charAt(0) == '/') start++; Matcher matcher = pattern.matcher(path); matcher.region(start, path.length()); return matcher.matches(); }
PathElement { public boolean matches(String path) { int start = 0; if (path.charAt(0) == '/') start++; Matcher matcher = pattern.matcher(path); matcher.region(start, path.length()); return matcher.matches(); } }
PathElement { public boolean matches(String path) { int start = 0; if (path.charAt(0) == '/') start++; Matcher matcher = pattern.matcher(path); matcher.region(start, path.length()); return matcher.matches(); } PathElement(String value, List<Group> groups, String regex); }
PathElement { public boolean matches(String path) { int start = 0; if (path.charAt(0) == '/') start++; Matcher matcher = pattern.matcher(path); matcher.region(start, path.length()); return matcher.matches(); } PathElement(String value, List<Group> groups, String regex); static PathElement pathElement(String path); String getValue(); boolean isTemplate(); boolean matches(String path); String resolve(String name, String path); }
PathElement { public boolean matches(String path) { int start = 0; if (path.charAt(0) == '/') start++; Matcher matcher = pattern.matcher(path); matcher.region(start, path.length()); return matcher.matches(); } PathElement(String value, List<Group> groups, String regex); static PathElement pathElement(String path); String getValue(); boolean isTemplate(); boolean matches(String path); String resolve(String name, String path);  }