Package proguard.util
Class WildcardManager
java.lang.Object
proguard.util.WildcardManager
This utility class creates and manages
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 Summary
ConstructorsConstructorDescriptionCreates a new WildcardManager.WildcardManager(WildcardManager wildcardManager) Creates a new WildcardManager with the current list of string matchers of the given WildcardManager. -
Method Summary
Modifier and TypeMethodDescriptioncreateMatchedStringFunction(String expression) Creates new StringFunction that transforms the given expression with possible references to wildcards, based on the list of string matchers.createMatchedStringMatcher(int index, StringMatcher nextMatcher) Creates new MatchedStringMatcher to match the the specified variable string matcher from the list of string matchers.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.voidrememberVariableStringMatcher(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.voidreset()Resets the list of string matchers.intwildCardIndex(String regularExpression, int index) Parses a reference to a wildcard at a given index, if any.
-
Constructor Details
-
WildcardManager
public WildcardManager()Creates a new WildcardManager. -
WildcardManager
Creates a new WildcardManager with the current list of string matchers of the given WildcardManager.
-
-
Method Details
-
reset
public void reset()Resets the list of string matchers. -
createVariableStringMatcher
public 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.- Parameters:
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.
-
rememberVariableStringMatcher
Remembers the given VariableStringMatcher as a next element in the list of string matchers, so it can be referenced by its index later. -
createMatchedStringMatcher
Creates new MatchedStringMatcher to match the the specified variable string matcher from the list of string matchers.- Parameters:
index- the 0-based index of previously created and remembered VariableStringMatcher instances.nextMatcher- an optional next matcher for the remainder of the string.
-
createMatchedStringFunction
Creates new StringFunction that transforms the given expression with possible references to wildcards, based on the list of string matchers.For example:
"foo<1>"returns a string function that prepends "foo" to the first wildcard of the recently matched string. -
wildCardIndex
Parses a reference to a wildcard at a given index, if any.For example:
"foo<1>"at index 0 returns -1,"foo<1>"at index 3 returns 0."foo<8>"at index 3 returns 7.- Parameters:
regularExpression- the regular expression.index- the index at which the regular expression is to be checked for a reference.- Returns:
- the 0-based index of the back reference, or -1 otherwise.
- Throws:
IllegalArgumentException- if the reference is malformed.
-