Package org.robovm.compiler.util
Class AntPathMatcher
java.lang.Object
org.robovm.compiler.util.AntPathMatcher
public class AntPathMatcher extends Object
PathMatcher implementation for Ant-style path patterns. Examples are provided below.
RoboVM note: This code was copied from the Apache Camel project. Part of this mapping code has been kindly borrowed from Apache Ant and Spring Framework.
The mapping matches URLs using the following rules:
- ? matches one character
- * matches zero or more characters
- ** matches zero or more 'directories' in a path
Some examples:
com/t?st.jsp- matchescom/test.jspbut alsocom/tast.jsporcom/txst.jspcom/*.jsp- matches all.jspfiles in thecomdirectorycom/**/test.jsp- matches alltest.jspfiles underneath thecompathorg/springframework/**/*.jsp- matches all.jspfiles underneath theorg/springframeworkpathorg/**/servlet/bla.jsp- matchesorg/springframework/servlet/bla.jspbut alsoorg/springframework/testing/servlet/bla.jspandorg/servlet/bla.jsp
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_PATH_SEPARATORDefault path separator: "/" -
Constructor Summary
Constructors Constructor Description AntPathMatcher(String pattern)AntPathMatcher(String pattern, String pathSeparator) -
Method Summary
Modifier and Type Method Description protected booleandoMatch(String path, boolean fullMatch, boolean isCaseSensitive)Actually match the givenpathagainst the givenpattern.StringextractPathWithinPattern(String pattern, String path)Given a pattern and a full path, determine the pattern-mapped part.static StringextractPattern(String input)static StringextractPattern(String input, String separator)static booleanisPattern(String pattern)Returnstrueif the specified pattern string contains wildcard characters.static booleanmatch(String pattern, String path)booleanmatches(String path)Matches the specified path against the pattern of thisAntPathMatcher.static StringrtrimWildcardTokens(String input)removes from a pattern all tokens to the right containing wildcardsstatic StringrtrimWildcardTokens(String input, String separator)voidsetPathSeparator(String pathSeparator)Set the path separator to use for pattern parsing.
-
Field Details
-
DEFAULT_PATH_SEPARATOR
Default path separator: "/"- See Also:
- Constant Field Values
-
-
Constructor Details
-
AntPathMatcher
-
AntPathMatcher
-
-
Method Details
-
setPathSeparator
Set the path separator to use for pattern parsing. Default is "/", as in Ant. -
matches
Matches the specified path against the pattern of thisAntPathMatcher.- Parameters:
path- the path to match.- Returns:
trueif a match was found.
-
isPattern
Returnstrueif the specified pattern string contains wildcard characters.- Returns:
trueif the specified string is an Ant-style pattern.
-
match
-
doMatch
Actually match the givenpathagainst the givenpattern.- Parameters:
path- the path String to testfullMatch- whether a full pattern match is required (else a pattern match as far as the given base path goes is sufficient)isCaseSensitive- Whether or not matching should be performed case sensitively.- Returns:
trueif the suppliedpathmatched,falseif it didn't
-
extractPathWithinPattern
Given a pattern and a full path, determine the pattern-mapped part.For example:
- '
/docs/cvs/commit.html' and '/docs/cvs/commit.html-> '' - '
/docs/*' and '/docs/cvs/commit-> 'cvs/commit' - '
/docs/cvs/*.html' and '/docs/cvs/commit.html-> 'commit.html' - '
/docs/**' and '/docs/cvs/commit-> 'cvs/commit' - '
/docs/**\/*.html' and '/docs/cvs/commit.html-> 'cvs/commit.html' - '
/*.html' and '/docs/cvs/commit.html-> 'docs/cvs/commit.html' - '
*.html' and '/docs/cvs/commit.html-> '/docs/cvs/commit.html' - '
*' and '/docs/cvs/commit.html-> '/docs/cvs/commit.html'
Assumes that
match(java.lang.String, java.lang.String)returnstruefor 'pattern' and 'path', but does not enforce this. - '
-
rtrimWildcardTokens
removes from a pattern all tokens to the right containing wildcards- Parameters:
input- the input string- Returns:
- the leftmost part of the pattern without wildcards
-
rtrimWildcardTokens
-
extractPattern
-
extractPattern
-