public class StandardSequenceHandler extends java.lang.Object implements SequenceHandler
Simple implementation of the SequenceHandler
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 special sequences.
This class is a bridge between arbitrary Tokenizer
implementations using the SPI interface SequenceHandler
and any
TokenizerProperties
implementation that does not
implement the SequenceHandler
interface itself.
SequenceHandler
,
Tokenizer
,
TokenizerProperties
Constructor and Description |
---|
StandardSequenceHandler(TokenizerProperties props)
The constructor takes the
TokenizerProperties
that provide the special sequences. |
Modifier and Type | Method and Description |
---|---|
int |
getSequenceMaxLength()
This method returns the length of the longest special sequence, comment or
string prefix that is known to this
SequenceHandler . |
boolean |
hasSequenceCommentOrString()
This method can be used by a
Tokenizer implementation
for a fast detection if special sequence checking must be performed at all. |
TokenizerProperty |
startsWithSequenceCommentOrString(DataProvider dataProvider)
This method checks if a given range of data starts with a special sequence,
a comment or a string.
|
public StandardSequenceHandler(TokenizerProperties props)
TokenizerProperties
that provide the special sequences.props
- the TokenizerProperties
to take the
sequences frompublic boolean hasSequenceCommentOrString()
Tokenizer
implementation
for a fast detection if special sequence checking must be performed at all.
If the method returns false
time-consuming preparations can be
skipped.hasSequenceCommentOrString
in interface SequenceHandler
true
if there actually are pattern that can be tested
for a match, false
otherwise.public TokenizerProperty startsWithSequenceCommentOrString(DataProvider dataProvider) throws java.lang.NullPointerException
null
if no special sequence, comment or string
could matches the the leading part of the data range given through the
DataProvider
.startsWithSequenceCommentOrString
in interface SequenceHandler
dataProvider
- the source to get the data range fromTokenizerProperty
if a special sequence,
comment or string could be detected, null
otherwisejava.lang.NullPointerException
- if no DataProvider
is givenpublic int getSequenceMaxLength()
SequenceHandler
. When
calling startsWithSequenceCommentOrString(de.susebox.jtopas.spi.DataProvider)
, the passed DataProvider
parameter will supply at least this number of characters (see DataProvider.getLength()
).
If less characters are provided, EOF is reached.
Tokenizer
(represented by the given DataProvider
) can supply enough data for
the startsWithSequenceCommentOrString(de.susebox.jtopas.spi.DataProvider)
method.getSequenceMaxLength
in interface SequenceHandler