public class WildCardPattern extends Object implements StringPattern
This is a thread-safe immutable class.
Example: The code snippet
StringPattern pattern = new WildCardPattern("Hello*");
System.out.println(pattern.matches("Hello world!"));
System.out.println(pattern.matches("Hi Jim!"));
will produce the output
true false
| Constructor and Description |
|---|
WildCardPattern(String pattern)
Creates an instance based on the specified pattern.
|
| Modifier and Type | Method and Description |
|---|---|
static StringPattern |
createFromsPatterns(String patterns,
String delimiters)
Returns a
StringPattern object based on a sequences of
wild-card patterns separated by the specified delimiter characters. |
boolean |
matches(String string)
Returns true if the specified string matches the pattern.
|
String |
toString()
Returns the pattern as delivered to the constructor.
|
public WildCardPattern(String pattern)
pattern - Pattern which may contain '*' wildcard characters.
Must be not null.public static StringPattern createFromsPatterns(String patterns, String delimiters)
StringPattern object based on a sequences of
wild-card patterns separated by the specified delimiter characters.
The return object matches a string if at least one of the
wild-card pattern matches.patterns - Wild-card patterns separated by delimiters defined
in delimiters. The actual pattern will be trimed.
That is, leading and trailing white-space characters are removed.delimiters - Recognized delimiters.public String toString()
public boolean matches(String string)
StringPatternmatches in interface StringPatternstring - String to be matched. Can be null.Copyright © 2014. All rights reserved.