public class StandardWhitespaceHandler extends java.lang.Object implements WhitespaceHandler
Simple implementation of the WhitespaceHandler
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 whitespaces.
This class is a bridge between arbitrary Tokenizer
implementations using the SPI interface WhitespaceHandler
and any
TokenizerProperties
implementation that does not
implement the WhitespaceHandler
interface itself.
WhitespaceHandler
,
Tokenizer
,
TokenizerProperties
Constructor and Description |
---|
StandardWhitespaceHandler(TokenizerProperties props)
The constructor takes the
TokenizerProperties
that provide the whitespaces. |
Modifier and Type | Method and Description |
---|---|
int |
countLeadingWhitespaces(DataProvider dataProvider)
This method detects the number of whitespace characters the data range given
through the
DataProvider parameter starts with. |
boolean |
isWhitespace(char testChar)
This method checks if the given character is a whitespace.
|
boolean |
newlineIsWhitespace()
If a
Tokenizer performs line counting, it is often
nessecary to know if newline characters is considered to be a whitespace. |
public StandardWhitespaceHandler(TokenizerProperties props)
TokenizerProperties
that provide the whitespaces.props
- the TokenizerProperties
to take the
whitespaces frompublic boolean isWhitespace(char testChar)
isWhitespace
in interface WhitespaceHandler
testChar
- check this charactertrue
if the given character is a whitespace,
false
otherwiseTokenizerProperties.setWhitespaces(java.lang.String)
public int countLeadingWhitespaces(DataProvider dataProvider) throws java.lang.NullPointerException
DataProvider
parameter starts with.countLeadingWhitespaces
in interface WhitespaceHandler
dataProvider
- the source to get the data range fromjava.lang.NullPointerException
- if no DataProvider
is givenDataProvider
public boolean newlineIsWhitespace()
Tokenizer
performs line counting, it is often
nessecary to know if newline characters is considered to be a whitespace.
See WhitespaceHandler
for details.newlineIsWhitespace
in interface WhitespaceHandler
true
if newline characters are in the current whitespace set,
false
otherwise