Package sk.antons.web.path
Class PathMatcher
- java.lang.Object
-
- sk.antons.web.path.PathMatcher
-
public class PathMatcher extends Object
Web path matching utility. Pattern to be matched can use- individual '?' character to represent any character
- individual '*' character to represent any sequence of characters except '/'
- path segment with only '*' character (more than one) to represent any sequence of path elements
- PathMatcher.instance("/foo/**") represents paths like /foo or /foo/bar/one
- PathMatcher.instance("/foo/*.xml") represents paths like /foo/a.xml or /foo/bar.xml
- PathMatcher.instance("/foo/?.xml") represents paths like /foo/a.xml or /foo/b.xml
- Author:
- antons
-
-
Constructor Summary
Constructors Constructor Description PathMatcher(String pattern, int maxSize)Creates PathMatcher with given pattern and defined max of path segments.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PathMatcherinstance(String pattern)Creates PathMatcher with given pattern and defined max of path segments.static PathMatcherinstance(String pattern, int maxSize)Creates PathMatcher with given pattern and defined max of path segments.booleanmatch(String path)Returns true if given path matches pattern.
-
-
-
Constructor Detail
-
PathMatcher
public PathMatcher(String pattern, int maxSize)
Creates PathMatcher with given pattern and defined max of path segments.- Parameters:
pattern- pattern for matching pathsmaxSize- maximal number path segments
-
-
Method Detail
-
instance
public static PathMatcher instance(String pattern)
Creates PathMatcher with given pattern and defined max of path segments. It limits path to 64 segments.- Parameters:
pattern- pattern for matching paths- Returns:
- new PathMatcher instance
-
instance
public static PathMatcher instance(String pattern, int maxSize)
Creates PathMatcher with given pattern and defined max of path segments.- Parameters:
pattern- pattern for matching pathsmaxSize- maximal size of path segments.- Returns:
- new PathMatcher instance
-
match
public boolean match(String path)
Returns true if given path matches pattern.- Parameters:
path- path to be matched- Returns:
- true if path matches
-
-