Package proguard.util

Class WildcardManager

java.lang.Object
proguard.util.WildcardManager

public class WildcardManager extends Object
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 Details

    • 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 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

      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(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(String regularExpression, int index) throws 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:
      IllegalArgumentException - if the reference is malformed.