public class StandardKeywordHandler extends java.lang.Object implements KeywordHandler
Simple implementation of the KeywordHandler
interface. This class
works only with the TokenizerProperties
interface
methods and is aware of changes in these properties. It does not cache any
information and is therefore a more or less slow way to handle keywords.
This class is a bridge between arbitrary Tokenizer
implementations using the SPI interface KeywordHandler
and any
TokenizerProperties
implementation that does not
implement the KeywordHandler
interface itself.
KeywordHandler
,
Tokenizer
,
TokenizerProperties
Constructor and Description |
---|
StandardKeywordHandler(TokenizerProperties props)
The constructor takes the
TokenizerProperties
that provide the keywords. |
Modifier and Type | Method and Description |
---|---|
boolean |
hasKeywords()
This method can be used by a
Tokenizer implementation
for a fast detection if keyword matching must be performed at all. |
TokenizerProperty |
isKeyword(DataProvider dataProvider)
This method checks if the character range given through the
DataProvider comprises a keyword. |
public StandardKeywordHandler(TokenizerProperties props)
TokenizerProperties
that provide the keywords.props
- the TokenizerProperties
to take the
keywords frompublic boolean hasKeywords()
Tokenizer
implementation
for a fast detection if keyword matching must be performed at all. If the method
returns false
time-consuming preparations can be skipped.hasKeywords
in interface KeywordHandler
true
if there actually are pattern that can be tested
for a match, false
otherwise.public TokenizerProperty isKeyword(DataProvider dataProvider) throws java.lang.NullPointerException
DataProvider
comprises a keyword.isKeyword
in interface KeywordHandler
dataProvider
- the source to get the data from, that are checkedTokenizerProperty
if a keyword could be
found, null
otherwiseTokenizerException
- failure while reading more datajava.lang.NullPointerException
- if no DataProvider
is given