Class PathMatcher

  • All Implemented Interfaces:
    Matcher

    public class PathMatcher
    extends java.lang.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​(java.lang.String regexpPath)
    • Method Detail

      • excludePath

        public PathMatcher excludePath​(java.lang.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
      • excludePaths

        public PathMatcher excludePaths​(java.lang.String... paths)
      • excludeBranch

        public PathMatcher excludeBranch​(java.lang.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​(java.lang.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
      • warn

        protected void warn()
      • matches

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

        public java.util.Set<java.lang.String> getExcludedPaths()
      • getExcludedPatterns

        public java.util.Set<java.util.regex.Pattern> getExcludedPatterns()
      • setExcludedPaths

        public void setExcludedPaths​(java.util.Collection<java.lang.String> paths)
      • setExcludedPatterns

        public void setExcludedPatterns​(java.util.Collection<java.lang.String> regularExpressions)
      • setExcludedPath

        public void setExcludedPath​(java.lang.String path)
      • setExcludedPattern

        public void setExcludedPattern​(java.lang.String regularExpression)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object