Package classycle.util
Class WildCardPattern
- java.lang.Object
-
- classycle.util.WildCardPattern
-
- All Implemented Interfaces:
StringPattern
public class WildCardPattern extends java.lang.Object implements StringPattern
Wildcard string pattern matching class. Only '*' is interpreted as wild card meaning the occurance of any number of arbitray characters.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 outputtrue false
- Author:
- Franz-Josef Elmer
-
-
Constructor Summary
Constructors Constructor Description WildCardPattern(java.lang.String pattern)
Creates an instance based on the specified pattern.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringPattern
createFromsPatterns(java.lang.String patterns, java.lang.String delimiters)
Returns aStringPattern
object based on a sequences of wild-card patterns separated by the specified delimiter characters.boolean
matches(java.lang.String string)
Returns true if the specified string matches the pattern.java.lang.String
toString()
Returns the pattern as delivered to the constructor.
-
-
-
Method Detail
-
createFromsPatterns
public static StringPattern createFromsPatterns(java.lang.String patterns, java.lang.String delimiters)
Returns aStringPattern
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.- Parameters:
patterns
- Wild-card patterns separated by delimiters defined in delimiters. The actual pattern will be trimmed. That is, leading and trailing white-space characters are removed.delimiters
- Recognized delimiters.
-
toString
public java.lang.String toString()
Returns the pattern as delivered to the constructor.- Overrides:
toString
in classjava.lang.Object
-
matches
public boolean matches(java.lang.String string)
Description copied from interface:StringPattern
Returns true if the specified string matches the pattern.- Specified by:
matches
in interfaceStringPattern
- Parameters:
string
- String to be matched. Can be null.- Returns:
- false if string == null.
-
-