@Test public void testEmptyGlobs() throws URISyntaxException { URIPattern pattern = new URIPattern("file:/a/*path"); Map<String, String> match = pattern.getMatch("file:/a"); Assert.assertNotNull(match); Assert.assertNull(match.get("path")); match = pattern.getMatch("file:/a/"); Assert.assertNotNull(match); Assert.assertEquals("", match.get("path")); match = pattern.getMatch("file:/a Assert.assertNotNull(match); Assert.assertEquals("/", match.get("path")); pattern = new URIPattern("file:/a/*path/:dataset"); match = pattern.getMatch("file:/a Assert.assertNotNull(match); Assert.assertEquals("", match.get("path")); match = pattern.getMatch("file:/a/dataset"); Assert.assertNotNull(match); Assert.assertNull(match.get("path")); pattern = new URIPattern("file:/*path"); match = pattern.getMatch("file:/"); Assert.assertNotNull(match); Assert.assertNull(match.get("path")); }
public Map<String, String> getMatch(URI uri) { if (pattern.isAbsolute()) { if (!pattern.getScheme().equalsIgnoreCase(uri.getScheme())) { return null; } } else if (uri.getScheme() != null) { return null; } Map<String, String> result = Maps.newLinkedHashMap(defaults); if (pattern.isOpaque()) { if (!uri.isOpaque()) { return null; } Iterator<String> pathQuery = PATH_QUERY_SPLITTER .split(uri.getRawSchemeSpecificPart()).iterator(); if (!addPath(patternPath, Iterators.getNext(pathQuery, null), result)) { return null; } addQuery(Iterators.getNext(pathQuery, null), result); } else if (!uri.isOpaque()) { addAuthority(uri, result); if (patternPath.isEmpty() && !uri.getRawPath().isEmpty()) { return null; } if (!addPath(patternPath, uri.getRawPath(), result)) { return null; } addQuery(uri.getRawQuery(), result); } else { return null; } if (!addComplexMatch(pattern.getFragment(), uri.getFragment(), result)) { return null; } this.lastMatch = result; return result; }
URIPattern { public Map<String, String> getMatch(URI uri) { if (pattern.isAbsolute()) { if (!pattern.getScheme().equalsIgnoreCase(uri.getScheme())) { return null; } } else if (uri.getScheme() != null) { return null; } Map<String, String> result = Maps.newLinkedHashMap(defaults); if (pattern.isOpaque()) { if (!uri.isOpaque()) { return null; } Iterator<String> pathQuery = PATH_QUERY_SPLITTER .split(uri.getRawSchemeSpecificPart()).iterator(); if (!addPath(patternPath, Iterators.getNext(pathQuery, null), result)) { return null; } addQuery(Iterators.getNext(pathQuery, null), result); } else if (!uri.isOpaque()) { addAuthority(uri, result); if (patternPath.isEmpty() && !uri.getRawPath().isEmpty()) { return null; } if (!addPath(patternPath, uri.getRawPath(), result)) { return null; } addQuery(uri.getRawQuery(), result); } else { return null; } if (!addComplexMatch(pattern.getFragment(), uri.getFragment(), result)) { return null; } this.lastMatch = result; return result; } }
URIPattern { public Map<String, String> getMatch(URI uri) { if (pattern.isAbsolute()) { if (!pattern.getScheme().equalsIgnoreCase(uri.getScheme())) { return null; } } else if (uri.getScheme() != null) { return null; } Map<String, String> result = Maps.newLinkedHashMap(defaults); if (pattern.isOpaque()) { if (!uri.isOpaque()) { return null; } Iterator<String> pathQuery = PATH_QUERY_SPLITTER .split(uri.getRawSchemeSpecificPart()).iterator(); if (!addPath(patternPath, Iterators.getNext(pathQuery, null), result)) { return null; } addQuery(Iterators.getNext(pathQuery, null), result); } else if (!uri.isOpaque()) { addAuthority(uri, result); if (patternPath.isEmpty() && !uri.getRawPath().isEmpty()) { return null; } if (!addPath(patternPath, uri.getRawPath(), result)) { return null; } addQuery(uri.getRawQuery(), result); } else { return null; } if (!addComplexMatch(pattern.getFragment(), uri.getFragment(), result)) { return null; } this.lastMatch = result; return result; } URIPattern(URI uri);  URIPattern(String uri); }
URIPattern { public Map<String, String> getMatch(URI uri) { if (pattern.isAbsolute()) { if (!pattern.getScheme().equalsIgnoreCase(uri.getScheme())) { return null; } } else if (uri.getScheme() != null) { return null; } Map<String, String> result = Maps.newLinkedHashMap(defaults); if (pattern.isOpaque()) { if (!uri.isOpaque()) { return null; } Iterator<String> pathQuery = PATH_QUERY_SPLITTER .split(uri.getRawSchemeSpecificPart()).iterator(); if (!addPath(patternPath, Iterators.getNext(pathQuery, null), result)) { return null; } addQuery(Iterators.getNext(pathQuery, null), result); } else if (!uri.isOpaque()) { addAuthority(uri, result); if (patternPath.isEmpty() && !uri.getRawPath().isEmpty()) { return null; } if (!addPath(patternPath, uri.getRawPath(), result)) { return null; } addQuery(uri.getRawQuery(), result); } else { return null; } if (!addComplexMatch(pattern.getFragment(), uri.getFragment(), result)) { return null; } this.lastMatch = result; return result; } URIPattern(URI uri);  URIPattern(String uri); String getScheme(); String getPatternString(); @Override boolean equals(Object o); @Override int hashCode(); URI construct(Map<String, String> options); boolean matches(URI uri); boolean matches(String uri); Map<String, String> getMatch(URI uri); Map<String, String> getMatch(String uri); Map<String, String> getLastMatch(); @Override String toString(); }
URIPattern { public Map<String, String> getMatch(URI uri) { if (pattern.isAbsolute()) { if (!pattern.getScheme().equalsIgnoreCase(uri.getScheme())) { return null; } } else if (uri.getScheme() != null) { return null; } Map<String, String> result = Maps.newLinkedHashMap(defaults); if (pattern.isOpaque()) { if (!uri.isOpaque()) { return null; } Iterator<String> pathQuery = PATH_QUERY_SPLITTER .split(uri.getRawSchemeSpecificPart()).iterator(); if (!addPath(patternPath, Iterators.getNext(pathQuery, null), result)) { return null; } addQuery(Iterators.getNext(pathQuery, null), result); } else if (!uri.isOpaque()) { addAuthority(uri, result); if (patternPath.isEmpty() && !uri.getRawPath().isEmpty()) { return null; } if (!addPath(patternPath, uri.getRawPath(), result)) { return null; } addQuery(uri.getRawQuery(), result); } else { return null; } if (!addComplexMatch(pattern.getFragment(), uri.getFragment(), result)) { return null; } this.lastMatch = result; return result; } URIPattern(URI uri);  URIPattern(String uri); String getScheme(); String getPatternString(); @Override boolean equals(Object o); @Override int hashCode(); URI construct(Map<String, String> options); boolean matches(URI uri); boolean matches(String uri); Map<String, String> getMatch(URI uri); Map<String, String> getMatch(String uri); Map<String, String> getLastMatch(); @Override String toString(); static final String SCHEME; static final String HOST; static final String PORT; static final String USERNAME; static final String PASSWORD; }