- java.lang.Object
-
- com.ibm.j9ddr.util.PatternString
-
- All Implemented Interfaces:
Serializable
public class PatternString extends Object implements Serializable
A string containing wildcards and other characters that enable it to represent many strings at once.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PatternString.PatternStringPair
A class to represent the PatternString in two separate patterns
-
Field Summary
Fields Modifier and Type Field Description static PatternString
ALWAYS_MATCHES
static char
singleCharWildCard
static char
wildCard
-
Constructor Summary
Constructors Constructor Description PatternString(String pattern)
Constructor for creating a PatternString class which can contain wildcard expressions and other characters to represent many strings at once.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
endsWith(String string)
Determine if there is a match to the pattern that ends with the given stringint[]
indexOf(int c)
Finds the indices of the possible first locations of the indicated character.boolean
isMatch(String string)
Determines if the pattern matches with a given string.boolean
isRegularString()
Checks if this PatternString contains no wildcards.static boolean
isWildcard(char c)
Checks if the provided character is a wildcardint[]
lastIndexOf(int c)
Finds the indices of the possible last locations of the indicated character.PatternString.PatternStringPair
split(int index)
Splits the patterns into two separate patterns, the splitting being done by the character at the indicated index, so this character is not included in either string.boolean
startsWith(String string)
Determine if there is a match to the pattern that starts with the given stringString
toString()
Gives the pattern used to create this PatternString class
-
-
-
Field Detail
-
wildCard
public static final char wildCard
- See Also:
- Constant Field Values
-
singleCharWildCard
public static final char singleCharWildCard
- See Also:
- Constant Field Values
-
ALWAYS_MATCHES
public static final PatternString ALWAYS_MATCHES
-
-
Constructor Detail
-
PatternString
public PatternString(String pattern)
Constructor for creating a PatternString class which can contain wildcard expressions and other characters to represent many strings at once.- Parameters:
pattern
- a String which can contain wildcards
-
-
Method Detail
-
split
public PatternString.PatternStringPair split(int index)
Splits the patterns into two separate patterns, the splitting being done by the character at the indicated index, so this character is not included in either string. If such a character is a variable length wildcard then the new patterns will begin and end with wildcards as needed.- Parameters:
index
- the index at which to split the PatternString in two parts
-
indexOf
public int[] indexOf(int c)
Finds the indices of the possible first locations of the indicated character. The results are returned in ascending order.- Parameters:
c
- index of the pattern within this PatternString- Returns:
- int[] an array indicating the possible first locations of the character indicated at the index provided.
-
lastIndexOf
public int[] lastIndexOf(int c)
Finds the indices of the possible last locations of the indicated character. The results are returned in descending order.- Parameters:
c
- index of the pattern within this PatternString- Returns:
- int[] an array indicating the possible last locations of the character indicated at the index provided.
-
isRegularString
public boolean isRegularString()
Checks if this PatternString contains no wildcards.- Returns:
- boolean true if this PatternString contains no wildcards, false otherwise
-
isWildcard
public static boolean isWildcard(char c)
Checks if the provided character is a wildcard- Parameters:
c
- the character to check whether it is a wildcard or not- Returns:
- boolean true if the character given is a wildcard
-
endsWith
public boolean endsWith(String string)
Determine if there is a match to the pattern that ends with the given string- Parameters:
string
- the String to match- Returns:
- boolean returns true if there is a match, false if not
-
isMatch
public boolean isMatch(String string)
Determines if the pattern matches with a given string.- Parameters:
string
- the String to match- Returns:
- boolean returns true if there is a match, false if not
-
startsWith
public boolean startsWith(String string)
Determine if there is a match to the pattern that starts with the given string- Parameters:
string
- the String to match- Returns:
- boolean returns true if there is a match, false if not
-
-