de.schlichtherle.util.regex
Class ThreadLocalMatcher

java.lang.Object
  extended by java.lang.ThreadLocal
      extended by de.schlichtherle.util.regex.ThreadLocalMatcher

public class ThreadLocalMatcher
extends ThreadLocal

A thread local Matcher. This class is intended to be used in multithreaded environments for high performance pattern matching.

Since:
TrueZIP 6.5 (refactored from inner class in de.schlichtherle.io.DefaultArchiveDetector)
Version:
TrueZIP 6.7
See Also:
reset(CharSequence)

Constructor Summary
ThreadLocalMatcher(Pattern pattern)
          Creates a new thread local matcher by using the given pattern.
ThreadLocalMatcher(String regex)
          Creates a new thread local matcher by compiling the given regex.
 
Method Summary
protected  Object initialValue()
           
 Matcher reset(CharSequence input)
          Resets the thread local matcher with the given character sequence and returns it.
 
Methods inherited from class java.lang.ThreadLocal
get, remove, set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadLocalMatcher

public ThreadLocalMatcher(String regex)
                   throws PatternSyntaxException
Creates a new thread local matcher by compiling the given regex.

Parameters:
regex - The expression to be compiled.
Throws:
PatternSyntaxException - If the expression's syntax is invalid.

ThreadLocalMatcher

public ThreadLocalMatcher(Pattern pattern)
Creates a new thread local matcher by using the given pattern.

Parameters:
pattern - The pattern to be used.
Throws:
NullPointerException - If the parameter is null.
Method Detail

initialValue

protected Object initialValue()
Overrides:
initialValue in class ThreadLocal

reset

public Matcher reset(CharSequence input)
Resets the thread local matcher with the given character sequence and returns it.