public class WildcardManager
extends java.lang.Object
StringMatcher
instances that (1) match wildcards,
and (2) refer back to matched wildcards.
Each instance represents a scope in which wildcards can be specified and referenced.
Constructor and Description |
---|
WildcardManager()
Creates a new WildcardManager.
|
WildcardManager(WildcardManager wildcardManager)
Creates a new WildcardManager with the current list of string matchers of the given
WildcardManager.
|
Modifier and Type | Method and Description |
---|---|
StringFunction |
createMatchedStringFunction(java.lang.String expression)
Creates new StringFunction that transforms the given expression with possible references to
wildcards, based on the list of string matchers.
|
MatchedStringMatcher |
createMatchedStringMatcher(int index,
StringMatcher nextMatcher)
Creates new MatchedStringMatcher to match the the specified variable string matcher from the
list of string matchers.
|
VariableStringMatcher |
createVariableStringMatcher(char[] allowedCharacters,
char[] disallowedCharacters,
int minimumLength,
int maximumLength,
StringMatcher nextMatcher)
Creates a new VariableStringMatcher and remembers it as a next element in the list of string
matchers, so it can be referenced by its index later.
|
void |
rememberVariableStringMatcher(VariableStringMatcher variableStringMatcher)
Remembers the given VariableStringMatcher as a next element in the list of string matchers, so
it can be referenced by its index later.
|
void |
reset()
Resets the list of string matchers.
|
int |
wildCardIndex(java.lang.String regularExpression,
int index)
Parses a reference to a wildcard at a given index, if any.
|
public WildcardManager()
public WildcardManager(WildcardManager wildcardManager)
public void reset()
public VariableStringMatcher createVariableStringMatcher(char[] allowedCharacters, char[] disallowedCharacters, int minimumLength, int maximumLength, StringMatcher nextMatcher)
allowedCharacters
- an optional list of allowed characters.disallowedCharacters
- an optional list of disallowed characters.minimumLength
- the minimum length of te variable string.maximumLength
- the maximum length of te variable string.nextMatcher
- an optional next matcher for the remainder of the string.public void rememberVariableStringMatcher(VariableStringMatcher variableStringMatcher)
public MatchedStringMatcher createMatchedStringMatcher(int index, StringMatcher nextMatcher)
index
- the 0-based index of previously created and remembered VariableStringMatcher
instances.nextMatcher
- an optional next matcher for the remainder of the string.public StringFunction createMatchedStringFunction(java.lang.String expression)
For example: "foo<1>" returns a string function that prepends "foo" to the first wildcard of the recently matched string.
public int wildCardIndex(java.lang.String regularExpression, int index) throws java.lang.IllegalArgumentException
For example: "foo<1>" at index 0 returns -1, "foo<1>" at index 3 returns 0. "foo<8>" at index 3 returns 7.
regularExpression
- the regular expression.index
- the index at which the regular expression is to be checked for a reference.java.lang.IllegalArgumentException
- if the reference is malformed.