org.gmetrics.util
[Groovy] Class WildcardPattern
java.lang.Object
org.gmetrics.util.WildcardPattern
class WildcardPattern
Represents a string pattern that may optionally include wildcards ('*', '**' or '?'), and
provides an API to determine whether that pattern matches a specified input string.
The wildcard character '*' within the pattern matches a sequence of zero or more characters within a
single file or directory name in the input string. It does not match a sequence of two or more
dir/file names. For instance, 'a*b' matches 'a12345b' and 'ab', but does NOT match 'a/b' or 'a123/b'.
The '**' wildcard matches any sequence of zero or more characters in the input string, including
directory names and separators . It matches any part of the directory tree. For instance, 'a**b'
matches 'a12345b', 'ab', 'a/b' and 'a1/a2/a3b'.
The wildcard character '?' within the pattern matches exactly one character in the input string,
excluding the normalized file separator character ('/').
This is an internal class and its API is subject to change.
- Authors:
- Chris Mair
- Version:
- \$Revision: 98 \$ - \$Date: 2010-03-09 21:45:10 -0500 (Tue, 09 Mar 2010) \$
Constructor Summary |
WildcardPattern(String patternString, boolean defaultMatches = true)
Construct a new WildcardPattern instance on a single pattern or a comma-separated list of patterns.
|
Method Summary |
boolean
|
matches(String string)
Return true if the specified String matches the pattern or if the original
patternString (specified in the constructor) was null or empty and the
value for defaultMatches (also specified in the constructor) was true.
|
WildcardPattern
WildcardPattern(String patternString, boolean defaultMatches = true)
- Construct a new WildcardPattern instance on a single pattern or a comma-separated list of patterns.
- Parameters:
patternString
- - the pattern string, optionally including wildcard characters ('*' or '?');
may optionally contain more than one pattern, separated by commas; may be null or empty to always matchdefaultMatches
- - a boolean indicating whether matches()
should
return true if the pattern string is either empty or null. This parameter is
optional and defaults to true
.
matches
boolean matches(String string)
- Return true if the specified String matches the pattern or if the original
patternString (specified in the constructor) was null or empty and the
value for defaultMatches (also specified in the constructor) was true.
- Parameters:
string
- - the String to check
- Returns:
- true if the String matches the pattern
Groovy Documentation