public NanoHTTPDAssertionDefinition(String path, int requestIndex) { m_requestIndex = requestIndex; m_pathString = path; m_path = new PathWildcardMatcher(path, true); }
@Override public PathWildcardMatcher transform(String pattern) { return new PathWildcardMatcher(pattern.trim(), true); } }));
public URLWildcardMatcher(final String wildCardUrlString, final boolean caseInsensitive) { try { m_wildCardURI = new URL(wildCardUrlString); m_protocolMatcher = new PathWildcardMatcher(m_wildCardURI.getProtocol(), caseInsensitive); m_hostMatcher = new PathWildcardMatcher(m_wildCardURI.getHost(), caseInsensitive); m_pathMatcher = new PathWildcardMatcher(m_wildCardURI.getPath(), caseInsensitive); if (m_wildCardURI.getQuery() != null) { m_queryMatcher = new PathWildcardMatcher(m_wildCardURI.getQuery(), caseInsensitive); } } catch (MalformedURLException e) { LOG.warn( "'" + wildCardUrlString + "' is not a valid URL, so only check for normal regexp match."); } m_fullURLMatcher = new PathWildcardMatcher(wildCardUrlString, caseInsensitive); }
protected boolean matches(final String wildCardString, final String testString) { PathWildcardMatcher p = new PathWildcardMatcher(wildCardString, true); boolean result = p.matches(testString != null ? testString : ""); if (LOG.isTraceEnabled()) { LOG.trace("'" + p.toString() + "' matches '" + testString + "' = " + result); } return result; } }
private boolean isContentTypeSupported(ContentType contentType, boolean allowWildCardSearch) { final String mimeType = contentType.getTypePart(); final Filter<String, String> f; if (allowWildCardSearch) { final PathWildcardMatcher matcher = new PathWildcardMatcher(mimeType, true); f = new AbstractFilter<String>() { @Override public boolean accept(String supportedMimeType) { return matcher.matches(supportedMimeType); } }; } else { f = new AbstractFilter<String>() { @Override public boolean accept(String supportedMimeType) { return mimeType.equalsIgnoreCase(supportedMimeType); } }; } return CollectionUtil.contains(m_supportedMimeTypes, f); }
m_mappedFactories.entrySet(); for (Entry<String, List<AuthenticationProcessorFactory>> entry : mappedFactories) { PathWildcardMatcher matcher = new PathWildcardMatcher(entry.getKey(), false); boolean matchesUri = matcher.matches(request.getRequestURI());