/** * Search the URI index to locale a match for the specified URI. * If found, return the args that represent the matched URI pattern tokens * and the values as per the supplied URI value. * * @param uri URI to match against the URI Templates in the index * * @return Map of token args to values or null if no match was found. */ public Map<String, String> findMatch(String uri) { Map<String, String> match = null; for (UriTemplate template : this.uriTemplates) { match = template.match(uri); if (match != null) { break; } } return match; } }
/** * Search the URI index to locale a match for the specified URI. * If found, return the args that represent the matched URI pattern tokens * and the values as per the supplied URI value. * * @param uri URI to match against the URI Templates in the index * * @return Map of token args to values or null if no match was found. */ public Map<String, String> findMatch(String uri) { Map<String, String> match = null; for (UriTemplate template : this.uriTemplates) { match = template.match(uri); if (match != null) { break; } } return match; } }
/** * Search the URI index to locale a match for the specified URI. * If found, return the args that represent the matched URI pattern tokens * and the values as per the supplied URI value. * * @param uri URI to match against the URI Templates in the index * * @return Map of token args to values or null if no match was found. */ public Map<String, String> findMatch(String uri) { for (UriTemplate template : this.mappings.keySet()) { Map<String, String> match = template.match(uri); if (match != null) { return match; } } // if we get here, no match was found return null; } }
/** * Search the URI index to locale a match for the specified URI. * If found, return the args that represent the matched URI pattern tokens * and the values as per the supplied URI value. * * @param uri URI to match against the URI Templates in the index * * @return Map of token args to values or null if no match was found. */ public Map<String, String> findMatch(String uri) { for (UriTemplate template : this.mappings.keySet()) { Map<String, String> match = template.match(uri); if (match != null) { return match; } } // if we get here, no match was found return null; } }
/** * Search the URI index to locate a match for the specified URI. * If found, return the matched URL with the tokens replaced as per the * pattern and supplied URI value. * * @param uri URI to match against the URI Templates in the index * * @return URI match with tokens replaced as per the URI Template pattern or * null if no match was found. */ public String findMatchAndReplace(String uri) { for (UriTemplate template : this.mappings.keySet()) { Map<String, String> match = template.match(uri); if (match != null) { // found a uri template match // so replace the tokens in the matched page with those from the uri return UriUtils.replaceUriTokens(this.mappings.get(template), match); } } // if we get here, no match was found return null; }
/** * Search the URI index to locate a match for the specified URI. * If found, return the matched URL with the tokens replaced as per the * pattern and supplied URI value. * * @param uri URI to match against the URI Templates in the index * * @return URI match with tokens replaced as per the URI Template pattern or * null if no match was found. */ public String findMatchAndReplace(String uri) { for (UriTemplate template : this.mappings.keySet()) { Map<String, String> match = template.match(uri); if (match != null) { // found a uri template match // so replace the tokens in the matched page with those from the uri return UriUtils.replaceUriTokens(this.mappings.get(template), match); } } // if we get here, no match was found return null; }
public void testTemplateDotMatch() { UriTemplate i1 = new UriTemplate("/a/b/{b}/c"); Map<String, String> values1 = i1.match("/a/b/x/y/z.ext/c"); assertEquals(1, values1.size()); assertEquals("x/y/z.ext", values1.get("b")); }
Map<String, String> vars = entry.getTemplate().match(test); if (vars != null)
Map<String, String> vars = entry.getTemplate().match(test); if (vars != null)
Map<String, String> vars = entry.getTemplate().match(test); if (vars != null)
public void testTemplateMatch() assertNull(i1.match("/")); assertNull(i1.match("/a")); assertNull(i1.match("/a/1/b")); assertNull(i1.match("/a/1/b/2")); assertNull(i1.match("/a/1/b/b2")); assertNull(i1.match("/a/1/b/b2b/")); Map<String, String> values1 = i1.match("/a/1/b/b2b"); assertNotNull(values1); assertEquals(2, values1.size()); Map<String, String> values2 = i2.match("/a/1/b/2/3"); assertNotNull(values2); assertEquals(2, values2.size()); Map<String, String> values3 = i3.match("/a/1/b/2"); assertNull(values3); Map<String, String> values4 = i4.match("/a/b/c"); assertEquals(2, values4.size()); assertEquals("", values4.get("b")); Map<String, String> values5 = i5.match("/a/bb/c"); assertEquals(2, values5.size()); assertEquals("b", values5.get("b"));