Save This Page
Home » openjdk-7 » sun » misc » [javadoc | source]
sun.misc
public class: RegexpPool [javadoc | source]
java.lang.Object
   sun.misc.RegexpPool
A class to represent a pool of regular expressions. A string can be matched against the whole pool all at once. It is much faster than doing individual regular expression matches one-by-one.
Constructor:
 public RegexpPool() 
Method from sun.misc.RegexpPool Summary:
add,   delete,   match,   matchNext,   print,   replace,   reset
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.misc.RegexpPool Detail:
 public  void add(String re,
    Object ret) throws REException 
    Add a regular expression to the pool of regular expressions.
 public Object delete(String re) 
    Delete the regular expression and its target.
 public Object match(String s) 
    Search for a match to a string & return the object associated with it with the match. When multiple regular expressions would match the string, the best match is returned first. The next best match is returned the next time matchNext is called.
 public Object matchNext(String s) 
    Identical to match except that it will only find matches to regular expressions that were added to the pool after the last regular expression that matched in the last call to match() or matchNext()
 public  void print(PrintStream out) 
    Print this pool to standard output
 public  void replace(String re,
    Object ret) 
    Replace the target for the regular expression with a different target.
 public  void reset() 
    Resets the pool so that the next call to matchNext looks at all regular expressions in the pool. match(s); is equivalent to reset(); matchNext(s);

    Multithreading note: reset/nextMatch leave state in the regular expression pool. If multiple threads could be using this pool this way, they should be syncronized to avoid race hazards. match() was done in such a way that there are no such race hazards: multiple threads can be matching in the same pool simultaneously.