Class PathMatcher

  • All Implemented Interfaces:
    Matcher

    public class PathMatcher
    extends Object
    implements Matcher
    Matches all request paths except whitelisted (excluded) paths.
    Since:
    2.0.0
    Author:
    Rob Ward
    • Constructor Detail

      • PathMatcher

        public PathMatcher()
      • PathMatcher

        public PathMatcher​(String regexpPath)
    • Method Detail

      • excludePath

        public PathMatcher excludePath​(String path)
        Any path exactly matching this string will be excluded. Use this method if you are excluding a specific path.
        Parameters:
        path - the path to be excluded
        Returns:
        this path matcher
      • excludeBranch

        public PathMatcher excludeBranch​(String path)
        Convenience method for excluding all paths starting with a prefix e.g. "/foo" would exclude "/foo", "/foo/bar", etc.
        Parameters:
        path - the prefix for the paths to be excluded
        Returns:
        this path matcher
      • excludeRegex

        public PathMatcher excludeRegex​(String regex)
        Any path matching this regex will be excluded.
        Parameters:
        regex - the regular expression matching the paths to be excluded
        Returns:
        this path matcher
      • matches

        public boolean matches​(WebContext context)
        Description copied from interface: Matcher
        Check if the web context matches.
        Specified by:
        matches in interface Matcher
        Parameters:
        context - the web context
        Returns:
        whether the web context matches
      • getExcludedPaths

        public Set<String> getExcludedPaths()
      • getExcludedPatterns

        public Set<Pattern> getExcludedPatterns()
      • setExcludedPatterns

        public void setExcludedPatterns​(Collection<String> regularExpressions)
      • setExcludedPath

        public void setExcludedPath​(String path)
      • setExcludedPattern

        public void setExcludedPattern​(String regularExpression)