public interface WhitespaceHandler
This interface declares the methods a Tokenizer
needs
to deal with whitespaces.
Whitespaces are single characters that separate other tokens. In programming
languages, the item whitespace also refers to comments. This does not apply
to a WhitespaceHandler
that only recognizes single characters.
Comments are handled by the SequenceHandler
interface.
Tokenizer
,
TokenizerProperties
,
DataMapper
,
SequenceHandler
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 (Carriage return and line feed) are
(currently) considered to be whitespaces, which is most often the case. |
boolean isWhitespace(char testChar)
testChar
- check this charactertrue
if the given character is a whitespace,
false
otherwiseTokenizerProperties.setWhitespaces(java.lang.String)
int countLeadingWhitespaces(DataProvider dataProvider) throws TokenizerException, java.lang.NullPointerException
DataProvider
parameter starts with. An implementation
should use a TokenizerException
to report problems.dataProvider
- the source to get the data range fromTokenizerException
- generic exceptionjava.lang.NullPointerException
- if no DataProvider
is givenDataProvider
boolean newlineIsWhitespace()
Tokenizer
performs line counting, it is often
nessecary to know if newline characters (Carriage return and line feed) are
(currently) considered to be whitespaces, which is most often the case.
This method informs interested callers about the current condition.
true
only if both newline
characters are part of the current whitespace set.true
if newline characters are in the current whitespace set,
false
otherwise