Class TokenizedPattern
- java.lang.Object
- 
- org.apache.tools.ant.types.selectors.TokenizedPattern
 
- 
 public class TokenizedPattern extends java.lang.ObjectProvides 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 SummaryFields Modifier and Type Field Description static TokenizedPatternEMPTY_PATTERNInstance that holds no tokens at all.
 - 
Constructor SummaryConstructors Constructor Description TokenizedPattern(java.lang.String pattern)Initialize the PathPattern by parsing it.
 - 
Method SummaryModifier and Type Method Description booleancontainsPattern(java.lang.String pat)Does the tokenized pattern contain the given string?intdepth()The depth (or length) of a pattern.booleanendsWith(java.lang.String s)true if the last token equals the given string.booleanequals(java.lang.Object o)true if the original patterns are equal.java.lang.StringgetPattern()inthashCode()booleanmatchPath(TokenizedPath path, boolean isCaseSensitive)Tests whether or not a given path matches a given pattern.booleanmatchStartOf(TokenizedPath path, boolean caseSensitive)Tests whether or not this pattern matches the start of a path.TokenizedPathrtrimWildcardTokens()Returns a new TokenizedPath where all tokens of this pattern to the right containing wildcards have been removedjava.lang.StringtoString()TokenizedPatternwithoutLastToken()Returns a new pattern without the last token of this pattern.
 
- 
- 
- 
Field Detail- 
EMPTY_PATTERNpublic static final TokenizedPattern EMPTY_PATTERN Instance that holds no tokens at all.
 
- 
 - 
Method Detail- 
matchPathpublic boolean matchPath(TokenizedPath path, boolean isCaseSensitive) Tests whether or not a given path matches a given pattern.- Parameters:
- path- The path to match, as a String. Must not be- null.
- isCaseSensitive- Whether or not matching should be performed case sensitively.
- Returns:
- trueif the pattern matches against the string, or- falseotherwise.
 
 - 
matchStartOfpublic boolean matchStartOf(TokenizedPath path, boolean caseSensitive) Tests whether or not this pattern matches the start of a path.- Parameters:
- path- TokenizedPath
- caseSensitive- boolean
- Returns:
- boolean
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
- Returns:
- The pattern String
 
 - 
getPatternpublic java.lang.String getPattern() 
 - 
equalspublic boolean equals(java.lang.Object o) true if the original patterns are equal.- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- o- Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
depthpublic int depth() The depth (or length) of a pattern.- Returns:
- int
 
 - 
containsPatternpublic boolean containsPattern(java.lang.String pat) Does the tokenized pattern contain the given string?- Parameters:
- pat- String
- Returns:
- boolean
 
 - 
rtrimWildcardTokenspublic TokenizedPath 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
 
 - 
endsWithpublic boolean endsWith(java.lang.String s) true if the last token equals the given string.- Parameters:
- s- String
- Returns:
- boolean
 
 - 
withoutLastTokenpublic TokenizedPattern withoutLastToken() Returns a new pattern without the last token of this pattern.- Returns:
- TokenizedPattern
 
 
- 
 
-