List of usage examples for org.springframework.util PatternMatchUtils simpleMatch
public static boolean simpleMatch(@Nullable String[] patterns, String str)
From source file:net.opentsdb.contrib.tsquare.WildcardAggregatorFactory.java
@Override public Aggregator getAggregatorForMetric(String metricName) { for (final Map.Entry<String, Aggregator> entry : aggregatorsByWildcard.entrySet()) { if (PatternMatchUtils.simpleMatch(entry.getKey(), metricName)) { log.debug("Metric {} matched wildcard {} -> {}", metricName, entry.getKey(), entry.getValue()); return entry.getValue(); }//from w ww.j av a 2 s . c o m } return null; }
From source file:uk.co.postoffice.spike.esi.helloworld.ThymeleafMasterLayoutViewResolver.java
protected boolean canHandle(final String viewName) { final String[] viewNamesToBeProcessed = getViewNames(); final String[] viewNamesNotToBeProcessed = getExcludedViewNames(); return ((viewNamesToBeProcessed == null || PatternMatchUtils.simpleMatch(viewNamesToBeProcessed, viewName)) && (viewNamesNotToBeProcessed == null || !PatternMatchUtils.simpleMatch(viewNamesNotToBeProcessed, viewName))); }
From source file:org.spring.guice.module.GuiceModuleMetadata.java
private boolean matches(String name) { if (includePatterns != null) { for (Pattern filter : includePatterns) { if (!filter.matcher(name).matches()) { return false; }/*from ww w . ja v a 2s. c o m*/ } } if (excludePatterns != null) { for (Pattern filter : excludePatterns) { if (filter.matcher(name).matches()) { return false; } } } if (includeNames != null && includeNames.length > 0) { if (!PatternMatchUtils.simpleMatch(includeNames, name)) { return false; } } if (excludeNames != null && excludeNames.length > 0) { if (PatternMatchUtils.simpleMatch(excludeNames, name)) { return false; } } return true; }
From source file:com.alibaba.druid.support.ibatis.SpringIbatisBeanTypeAutoProxyCreator.java
/** * Return if the given bean name matches the mapped name. * <p>/*ww w . jav a 2 s. c om*/ * The default implementation checks for "xxx*", "*xxx" and "*xxx*" matches, as well as direct equality. Can be * overridden in subclasses. * * @param beanName the bean name to check * @param mappedName the name in the configured list of names * @return if the names match * @see org.springframework.util.PatternMatchUtils#simpleMatch(String, String) */ protected boolean isMatch(String beanName, String mappedName) { return PatternMatchUtils.simpleMatch(mappedName, beanName); }
From source file:com.developmentsprint.spring.breaker.interceptor.NameMatchCircuitBreakerAttributeSource.java
/** * Return if the given method name matches the mapped name. * <p>/*from w ww .j a v a 2 s .c o m*/ * The default implementation checks for "xxx*", "*xxx" and "*xxx*" matches, as well as direct equality. Can be overridden in subclasses. * * @param methodName * the method name of the class * @param mappedName * the name in the descriptor * @return if the names match * @see org.springframework.util.PatternMatchUtils#simpleMatch(String, String) */ protected boolean isMatch(String methodName, String mappedName) { return PatternMatchUtils.simpleMatch(mappedName, methodName); }
From source file:com.gisgraphy.webapp.filter.StaticFilter.java
/** * This method checks to see if the current path matches includes or * excludes. If it matches includes and not excludes, it forwards to the * static resource and ends the filter chain. Otherwise, it forwards to the * next filter in the chain./*from www. ja v a 2 s . c om*/ * * @param request * the current request * @param response * the current response * @param chain * the filter chain * @throws ServletException * when something goes wrong * @throws IOException * when something goes terribly wrong */ @Override public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { UrlPathHelper urlPathHelper = new UrlPathHelper(); String path = urlPathHelper.getPathWithinApplication(request); boolean pathExcluded = PatternMatchUtils.simpleMatch(excludes, path); boolean pathIncluded = PatternMatchUtils.simpleMatch(includes, path); if (pathIncluded && !pathExcluded) { if (logger.isDebugEnabled()) { logger.debug("Forwarding to static resource: " + path); } if (path.contains(".html")) { response.setContentType("text/html"); } RequestDispatcher rd = getServletContext().getRequestDispatcher(path); rd.include(request, response); return; } if (servletName != null) { RequestDispatcher rd = getServletContext().getNamedDispatcher(servletName); rd.forward(request, response); return; } chain.doFilter(request, response); }
From source file:ejportal.webapp.filter.StaticFilter.java
/** * This method checks to see if the current path matches includes or * excludes. If it matches includes and not excludes, it forwards to the * static resource and ends the filter chain. Otherwise, it forwards to the * next filter in the chain./*from w w w .j a v a2 s .c o m*/ * * @param request * the current request * @param response * the current response * @param chain * the filter chain * @throws IOException * when something goes terribly wrong * @throws ServletException * when something goes wrong */ @Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws IOException, ServletException { final UrlPathHelper urlPathHelper = new UrlPathHelper(); final String path = urlPathHelper.getPathWithinApplication(request); final boolean pathExcluded = PatternMatchUtils.simpleMatch(this.excludes, path); final boolean pathIncluded = PatternMatchUtils.simpleMatch(this.includes, path); if (pathIncluded && !pathExcluded) { if (this.logger.isDebugEnabled()) { this.logger.debug("Forwarding to static resource: " + path); } if (path.contains(".html")) { response.setContentType("text/html"); } final RequestDispatcher rd = this.getServletContext().getRequestDispatcher(path); rd.include(request, response); return; } if (this.servletName != null) { final RequestDispatcher rd = this.getServletContext().getNamedDispatcher(this.servletName); rd.forward(request, response); return; } chain.doFilter(request, response); }
From source file:org.shept.util.FtpFileCopy.java
protected boolean acceptFile(FTPFile file, String pattern) { if (file.isDirectory()) return false; return PatternMatchUtils.simpleMatch(pattern, file.getName()); }
From source file:com.usefullc.platform.common.filter.WebCommonFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; // String url = req.getRequestURL().toString(); String url = req.getRequestURI(); if (canExcute) { Stack<ActionHandlerInterceptor> actionStack = new Stack<ActionHandlerInterceptor>(); ActionHandler actionHandler = new ActionHandler(req, res); for (ActionHandlerInterceptor interceptor : interceptorList) { String urlPattern = interceptor.getUrlPattern(); // ?url Boolean state = PatternMatchUtils.simpleMatch(urlPattern, url); if (!state) { continue; }/*from w w w . j a v a 2s. c o m*/ interceptor.beforeHandler(actionHandler); // actionStack.push(interceptor); } boolean actionState = false; try { chain.doFilter(request, response); actionState = true; } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter print = new PrintWriter(sw); e.printStackTrace(print); actionHandler.setErrMsg(sw.toString()); } finally { // actionHandler.setState(actionState); while (!actionStack.isEmpty()) { ActionHandlerInterceptor interceptor = actionStack.pop(); interceptor.afterHandler(actionHandler); } } } else { chain.doFilter(request, response); } }
From source file:com.usefullc.platform.common.filter.WebCommonFilter.java
public static void main(String[] args) { String url = "http://wwww.fsd.co/query/11111.htm1"; AntPathMatcher antMatcher = new AntPathMatcher(); Boolean state = PatternMatchUtils.simpleMatch("*.htm", url); System.out.println(state);// www.j ava 2 s . c o m }