Package proguard.util
Class WildcardManager
- java.lang.Object
-
- proguard.util.WildcardManager
-
public class WildcardManager extends java.lang.Object
This utility class creates and managesStringMatcher
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
Constructors Constructor Description WildcardManager()
Creates a new WildcardManager.WildcardManager(WildcardManager wildcardManager)
Creates a new WildcardManager with the current list of string matchers of the given WildcardManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Constructor Detail
-
WildcardManager
public WildcardManager()
Creates a new WildcardManager.
-
WildcardManager
public WildcardManager(WildcardManager wildcardManager)
Creates a new WildcardManager with the current list of string matchers of the given WildcardManager.
-
-
Method Detail
-
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
public 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.
-
createMatchedStringMatcher
public MatchedStringMatcher createMatchedStringMatcher(int index, StringMatcher nextMatcher)
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
public 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.For example: "foo<1>" returns a string function that prepends "foo" to the first wildcard of the recently matched string.
-
wildCardIndex
public int wildCardIndex(java.lang.String regularExpression, int index) throws java.lang.IllegalArgumentException
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:
java.lang.IllegalArgumentException
- if the reference is malformed.
-
-