Class HoconTokenizer

java.lang.Object
org.apache.juneau.marshall.hocon.HoconTokenizer

public class HoconTokenizer extends Object
Tokenizer for HOCON (Human-Optimized Config Object Notation) format.

Handles unquoted strings, quoted strings, triple-quoted strings, numbers, booleans, null, structural tokens, substitutions (${var} and ${?var}), and comments.

See Also:
  • Constructor Details

    • HoconTokenizer

      public HoconTokenizer(Reader reader)
      Constructor.
      Parameters:
      reader - The reader to tokenize.
      Must not be null.
  • Method Details

    • getLine

      public int getLine()
      Returns the current line number (1-based).
      Returns:
      The line number.
    • getColumn

      public int 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 call skipWhitespaceAndCommentsExceptNewlines() 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

      public void skipWhitespaceAndComments() throws IOException
      Skips whitespace and comments.

      No-op when a token has already been peeked (i.e. peek() or peekNoSkip() 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.