public interface PatternHandler
This interface must be implemented by classes that should be used as a
pattern handler for a Tokenizer
. Pattern are usually
regular expressions that are applied on token images to check if that image
matches the pattern.
Tokenizer
,
TokenizerProperties
,
DataMapper
Modifier and Type | Interface and Description |
---|---|
static interface |
PatternHandler.Result
An inner interface for the pattern match result.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasPattern()
This method can be used by a
Tokenizer implementation
for a fast detection if pattern matching must be performed at all. |
PatternHandler.Result |
matches(DataProvider dataProvider)
This method checks if the start of a character range given through the
DataProvider matches a pattern. |
boolean hasPattern()
Tokenizer
implementation
for a fast detection if pattern matching must be performed at all. If the method
returns false
time-consuming preparations can be skipped.true
if there actually are pattern that can be tested
for a match, false
otherwise.PatternHandler.Result matches(DataProvider dataProvider) throws TokenizerException, java.lang.NullPointerException
DataProvider
matches a pattern. An implementation should use
a TokenizerException
to report problems.
null
if the beginning of the character range
doesn't match a pattern known to the PatternHandler
. Otherwise
it returns an object with the implemented interface PatternHandler.Result
.
dataProvider
- the source to get the data fromlengthOfMatch
- if a match is found, the method places the length of
it into the first element of this arrayPatternHandler.Result
object or null
if no
match was foundTokenizerException
- generic exceptionjava.lang.NullPointerException
- if no DataProvider
is given