Class HoconTokenizer
Handles unquoted strings, quoted strings, triple-quoted strings, numbers, booleans, null,
structural tokens, substitutions (${var} and ${?var}), and comments.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA token with optional string or number value.static enumToken types produced by the tokenizer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the current column number (1-based).intgetLine()Returns the current line number (1-based).peek()Peeks at the next token without consuming it.Peeks at the next token without skipping whitespace first.read()Reads and consumes the next token.Reads a quoted string ("..." or '...') with JSON-style escaping.Reads a triple-quoted string ("""...""").Reads an unquoted string until a forbidden character.voidSkips whitespace and comments.voidSkips whitespace and comments but stops at newlines.
-
Constructor Details
-
HoconTokenizer
Constructor.- Parameters:
reader- The reader to tokenize.
Must not benull .
-
-
Method Details
-
getLine
Returns the current line number (1-based).- Returns:
- The line number.
-
getColumn
Returns the current column number (1-based).- Returns:
- The column number.
-
peek
Peeks at the next token without consuming it.- Returns:
- The next token.
- Throws:
IOException- If a read error occurs.
-
peekNoSkip
Peeks at the next token without skipping whitespace first. Caller must callskipWhitespaceAndCommentsExceptNewlines()first when checking for value concatenation.- Returns:
- The next token.
- Throws:
IOException- If a read error occurs.
-
read
Reads and consumes the next token.- Returns:
- The next token.
- Throws:
IOException- If a read error occurs.
-
skipWhitespaceAndComments
Skips whitespace and comments.No-op when a token has already been peeked (i.e.
peek()orpeekNoSkip()cached a token). Once a token is cached, the underlying reader is positioned after that token, so skipping whitespace here would consume characters that semantically come after the cached token rather than before it. The leading whitespace before the cached token was already consumed when the token was produced, so this method has nothing left to do until the cached token is read. This invariant keeps callers from accidentally reading past a peeked structural token (such as a closing]or }) and swallowing a separator that belongs to an enclosing scope.- Throws:
IOException- If a read error occurs.
-
skipWhitespaceAndCommentsExceptNewlines
Skips whitespace and comments but stops at newlines. Used when parsing value concatenation so newlines end the value.- Throws:
IOException- If a read error occurs.
-
readQuotedString
Reads a quoted string ("..." or '...') with JSON-style escaping.- Returns:
- The string value.
- Throws:
IOException- If a read error occurs.
-
readUnquotedString
Reads an unquoted string until a forbidden character.- Returns:
- The string value.
- Throws:
IOException- If a read error occurs.
-
readTripleQuotedString
Reads a triple-quoted string ("""..."""). No escape processing inside per HOCON spec.- Returns:
- The string value.
- Throws:
IOException- If a read error occurs.
-