RegexTrie
  public
  
  
  
  class
  RegexTrie
  
    extends Object
  
  
  
  
  
  
  
    
    | java.lang.Object | 
  
  
    
      | ↳ | com.android.tradefed.util.RegexTrie<V> | 
  
  
    
  The RegexTrie is a trie where each stored segment of the key is a regex
 ERROR(/Pattern).  Thus, the full stored key is a List<Pattern> rather
 than a List<String> as in a standard trie.  Note that the
 retrieve(String) method will be pointwise matched against the Patterns,
 rather than checked for pointwise equality as in a standard trie.  Because of this, it may
 perform poorly for large datasets.
 
 One can also use a 
null entry in the 
Pattern sequence to serve as a wildcard.  If
 a 
null is encountered, all subsequent entries in the sequence will be ignored.
 When the retrieval code encounters a 
null Pattern, it will first wait to see if a
 more-specific entry matches the sequence.  If one does, that more-specific entry will proceed,
 even if it subsequently fails to match.
 
 If no more-specific entry matches, the wildcard match will add all remaining 
Strings
 to the list of captures (if enabled) and return the value associated with the wildcard.
 
 A short sample of the wildcard functionality:
 
 List<List<String>> captures = new LinkedList<List<String>>();
 RegexTrie<Integer> trie = new RegexTrie<Integer>();
 trie.put(2, "a", null);
 trie.put(4, "a", "b");
 trie.retrieve(captures, "a", "c", "e");
 // returns 2.  captures is now [[], ["c"], ["e"]]
 trie.retrieve(captures, "a", "b");
 // returns 4.  captures is now [[], []]
 trie.retrieve(captures, "a", "b", "c");
 // returns null.  captures is now [[], []]
 
Summary
| Public methods | 
|---|
  
  
  
    | 
        
        
        
        
        
        void | 
      clear()
       | 
  
  
  
  
    | 
        
        
        
        
        
        V | 
      put(V value, Pattern... patterns)
      Add an entry to the trie.
        
    
 | 
  
  
  
  
    | 
        
        
        
        
        
        V | 
      retrieve(String... strings)
      Fetch a value from the trie, by matching the provided sequence of Strings to a
 sequence ofERROR(/Pattern)s stored in the trie. | 
  
  
  
  
    | 
        
        
        
        
        
        V | 
      retrieve( captures, String... strings)
      Fetch a value from the trie, by matching the provided sequence of Strings to a
 sequence ofERROR(/Pattern)s stored in the trie. | 
  
  
  
  
    | 
        
        
        
        
        
        String | 
      toString()
       | 
  
Public constructors
    RegexTrie
    
public RegexTrie ()
    
    
    
  
 
Public methods
    clear
    
public void clear ()
    
    
    
  
 
    put
    
public V put (V value, 
                Pattern... patterns)
    
    
    
  Add an entry to the trie.
    
    | Parameters | 
|---|
      
        | value | V: The value to set | 
      
        | patterns | Pattern: The sequence ofERROR(/Pattern)s that must be sequentially matched to
        retrieve the associatedvalue | 
    
    
 
    retrieve
    
public V retrieve (String... strings)
    
    
    
  Fetch a value from the trie, by matching the provided sequence of Strings to a
 sequence of ERROR(/Pattern)s stored in the trie.
    
    | Parameters | 
|---|
      
        | strings | String: A sequence ofStrings to match | 
    
    
      | Returns | 
|---|
      
        | V | The associated value, or nullif no value was found | 
    
 
    retrieve
    
public V retrieve ( captures, 
                String... strings)
    
    
    
  Fetch a value from the trie, by matching the provided sequence of Strings to a
 sequence of ERROR(/Pattern)s stored in the trie.  This version of the method also returns
 a ERROR(/List) of capture groups for each ERROR(/Pattern) that was matched.
 
 Each entry in the outer List corresponds to one level of 
Pattern in the trie.
 For each level, the list of capture groups will be stored.  If there were no captures
 for a particular level, an empty list will be stored.
 
 Note that 
captures will be 
ERROR(/List#clear())ed before the retrieval begins.
 Also, if the retrieval fails after a partial sequence of matches, 
captures will
 still reflect the capture groups from the partial match.
    
    | Parameters | 
|---|
      
        | captures | : AList<List<String>>through which capture groups will be returned. | 
      
        | strings | String: A sequence ofStrings to match | 
    
    
      | Returns | 
|---|
      
        | V | The associated value, or nullif no value was found | 
    
 
    toString
    
public String toString ()