Package org.apache.juneau.marshall.hjson
Class HjsonTokenizer
java.lang.Object
org.apache.juneau.marshall.hjson.HjsonTokenizer
Tokenizer for Hjson format.
Handles quoted strings, quoteless strings, multiline strings, comments, numbers, booleans, null, and structural tokens.
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.read()Reads and consumes the next token.readMultilineString(int indentBaseline) Reads a multiline string ('''...''').Reads a quoted string ("..." or '...') with JSON-style escaping.Reads a quoteless string (to end of line, trimmed).voidSkips whitespace and comments.
-
Constructor Details
-
HjsonTokenizer
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.
-
read
Reads and consumes the next token.- Returns:
- The next token.
- Throws:
IOException- If a read error occurs.
-
skipWhitespaceAndComments
Skips whitespace and comments.- 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.
-
readQuotelessString
Reads a quoteless string (to end of line, trimmed).- Returns:
- The string value.
- Throws:
IOException- If a read error occurs.
-
readMultilineString
Reads a multiline string ('''...'''). Caller must have already consumed the opening '''.- Parameters:
indentBaseline- The 1-based column of the first quote in '''; used to strip leading indentation from subsequent lines per Hjson spec.- Returns:
- The string value (with \n line separators, last newline ignored per spec).
- Throws:
IOException- If a read error occurs.
-