Class TokenizedPattern
java.lang.Object
org.apache.tools.ant.types.selectors.TokenizedPattern
Provides reusable path pattern matching. PathPattern is preferable
to equivalent SelectorUtils methods if you need to execute multiple
matching with the same pattern because here the pattern itself will
be parsed only once.
- Since:
- 1.8.0
- See Also:
SelectorUtils.matchPath(String, String)
,SelectorUtils.matchPath(String, String, boolean)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsPattern(String pat)
Does the tokenized pattern contain the given string?int
depth()
The depth (or length) of a pattern.boolean
true if the last token equals the given string.boolean
true if the original patterns are equal.int
hashCode()
boolean
matchPath(TokenizedPath path, boolean isCaseSensitive)
Tests whether or not a given path matches a given pattern.boolean
matchStartOf(TokenizedPath path, boolean caseSensitive)
Tests whether or not this pattern matches the start of a path.Returns a new TokenizedPath where all tokens of this pattern to the right containing wildcards have been removedtoString()
Returns a new pattern without the last token of this pattern.
-
Field Details
-
EMPTY_PATTERN
Instance that holds no tokens at all.
-
-
Constructor Details
-
TokenizedPattern
Initialize the PathPattern by parsing it.- Parameters:
pattern
- The pattern to match against. Must not benull
.
-
-
Method Details
-
matchPath
Tests whether or not a given path matches a given pattern.- Parameters:
path
- The path to match, as a String. Must not benull
.isCaseSensitive
- Whether or not matching should be performed case sensitively.- Returns:
true
if the pattern matches against the string, orfalse
otherwise.
-
matchStartOf
Tests whether or not this pattern matches the start of a path.- Parameters:
path
- TokenizedPathcaseSensitive
- boolean- Returns:
- boolean
-
toString
-
getPattern
-
equals
true if the original patterns are equal. -
hashCode
public int hashCode() -
depth
public int depth()The depth (or length) of a pattern.- Returns:
- int
-
containsPattern
Does the tokenized pattern contain the given string?- Parameters:
pat
- String- Returns:
- boolean
-
rtrimWildcardTokens
Returns a new TokenizedPath where all tokens of this pattern to the right containing wildcards have been removed- Returns:
- the leftmost part of the pattern without wildcards
-
endsWith
true if the last token equals the given string.- Parameters:
s
- String- Returns:
- boolean
-
withoutLastToken
Returns a new pattern without the last token of this pattern.- Returns:
- TokenizedPattern
-