Package jodd.util
Class Wildcard
java.lang.Object
jodd.util.Wildcard
Checks whether a string or path matches a given wildcard pattern.
Possible patterns allow to match single characters ('?') or any count of
characters ('*'). Wildcard characters can be escaped (by an '\').
When matching path, deep tree wildcard also can be used ('**').
This method uses recursive matching, as in linux or windows. regexp works the same. This method is very fast, comparing to similar implementations.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanequalsOrMatch(CharSequence string, CharSequence pattern) Checks if two strings are equals or if theymatch(CharSequence, CharSequence).static booleanmatch(CharSequence string, CharSequence pattern) Checks whether a string matches a given wildcard pattern.private static booleanmatch(CharSequence string, CharSequence pattern, int sNdx, int pNdx) Internal matching recursive function.static intMatches string to at least one pattern.static booleanMatches path against pattern using *, ? and ** wildcards.static intmatchPathOne(String path, String... patterns) Matches path to at least one pattern.protected static booleanmatchTokens(String[] tokens, String[] patterns) Match tokenized string and pattern.
-
Field Details
-
PATH_MATCH
- See Also:
-
PATH_SEPARATORS
- See Also:
-
-
Constructor Details
-
Wildcard
public Wildcard()
-
-
Method Details
-
match
Checks whether a string matches a given wildcard pattern.- Parameters:
string- input stringpattern- pattern to match- Returns:
trueif string matches the pattern, otherwisefalse
-
equalsOrMatch
Checks if two strings are equals or if theymatch(CharSequence, CharSequence). Useful for cases when matching a lot of equal strings and speed is important. -
match
Internal matching recursive function. -
matchOne
Matches string to at least one pattern. Returns index of matched pattern, or-1otherwise.- See Also:
-
matchPathOne
Matches path to at least one pattern. Returns index of matched pattern or-1otherwise.- See Also:
-
matchPath
Matches path against pattern using *, ? and ** wildcards. Both path and the pattern are tokenized on path separators (both \ and /). '**' represents deep tree wildcard, as in Ant. -
matchTokens
Match tokenized string and pattern.
-