public interface TokenControl
Offers methods to control the parsing process by the handler.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Disable the handling of all types of comments.void
disableComments
(int type) Disable the handling of comments of the given type.void
Enable the handling of all types of comments.void
enableComments
(int type) Enable the handling of comments of the given type.Get the currentTokenHandler
.void
setAcceptEofEndingQuoted
(boolean accept) If set, quoted strings ending with an EOF (End Of File). are processed through the relevantquoted
method, albeit an error is reported in any case.void
setAcceptNewlineEndingQuote
(boolean accept) If set, quoted strings ending with an unescaped newline (instead of the closing quote) are processed through the relevantquoted
method, albeit an error is reported in any case.void
setExternalLocationHandling
(boolean enable) Enable/disable the external handling of locations.void
setLocationTo
(LocatorAccess locator) Set the current parsing location to the given locator.void
setLocationTo
(LocatorAccess locator, int index) Set the parsing location given byindex
to the given locator.void
setTokenHandler
(TokenHandler3<?> handler) Set a newTokenHandler
.int
Gives the next code point in the stream, bypassing the general processing for that one.
-
Method Details
-
enableAllComments
void enableAllComments()Enable the handling of all types of comments. -
setAcceptNewlineEndingQuote
void setAcceptNewlineEndingQuote(boolean accept) If set, quoted strings ending with an unescaped newline (instead of the closing quote) are processed through the relevantquoted
method, albeit an error is reported in any case. Otherwise, only the error is reported.It is set to
false
by default.- Parameters:
accept
- true to process quoted strings that ends with an unescaped newline, false otherwise.
-
setAcceptEofEndingQuoted
void setAcceptEofEndingQuoted(boolean accept) If set, quoted strings ending with an EOF (End Of File). are processed through the relevantquoted
method, albeit an error is reported in any case. Otherwise, only the error is reported.It is set to
false
by default.- Parameters:
accept
- true to process quoted strings that ends with an EOF,false
otherwise.
-
skipNextCodepoint
Gives the next code point in the stream, bypassing the general processing for that one.- Returns:
- the next code point, or -1 if the end of the stream was reached.
- Throws:
IOException
- if an I/O problem occurs.
-
getTokenHandler
TokenHandler3<?> getTokenHandler()Get the currentTokenHandler
.- Returns:
- the
TokenHandler
.
-
setTokenHandler
Set a newTokenHandler
.- Parameters:
handler
- the newTokenHandler
.
-
disableAllComments
void disableAllComments()Disable the handling of all types of comments. -
enableComments
void enableComments(int type) Enable the handling of comments of the given type.- Parameters:
type
- the type of comment to enable. If the type does not exist, implementations may or may not throw an exception, depending on the intended coupling with theTokenHandler
.
-
disableComments
void disableComments(int type) Disable the handling of comments of the given type.- Parameters:
type
- the type of comment to disable. If the type does not exist, implementations may or may not throw an exception, depending on the intended coupling with theTokenHandler
.
-
setExternalLocationHandling
void setExternalLocationHandling(boolean enable) Enable/disable the external handling of locations.If a binary stream is being processed, it should be enabled. It is enabled by default.
- Parameters:
enable
- iffalse
, this parser will take care of handling CR/LF/FF control characters and location housekeeping. Otherwise, all control characters are sent to the handler without further processing.
-
setLocationTo
Set the current parsing location to the given locator.Will only work correctly if
externalLocationHandling
is disabled.- Parameters:
locator
- the locator.- See Also:
-
setLocationTo
Set the parsing location given byindex
to the given locator.Will only work correctly if
externalLocationHandling
is disabled and theindex
points at the same line that the current parsing location.- Parameters:
locator
- the locator.index
- the index at which the location is to be set.- See Also:
-