Package org.tomlj

Class TomlParseOptions

java.lang.Object
org.tomlj.TomlParseOptions

@DefaultQualifier(value=org.checkerframework.checker.nullness.qual.NonNull.class, locations={RETURN,PARAMETER,FIELD}) public final class TomlParseOptions extends Object
Options controlling how a TOML document is parsed.
  • Field Details

  • Method Details

    • defaults

      public static TomlParseOptions defaults()
      The default parse options: TomlVersion.LATEST, with a maximum nesting depth of 128.
      Returns:
      The default parse options.
    • withVersion

      public TomlParseOptions withVersion(TomlVersion version)
      Create a copy of these options that parses at a different specification version.
      Parameters:
      version - The version level to parse at.
      Returns:
      A new set of options with the given version.
    • withMaxNestingDepth

      public TomlParseOptions withMaxNestingDepth(int maxNestingDepth)
      Create a copy of these options that allows a different maximum nesting depth.

      The depth of a value, table or array is the number of tables and arrays that enclose it, not counting the root table. For example:

      • In a = [[1]] the integer 1 is nested 2 deep (the outer and inner arrays).
      • In a.b.c = 1 the integer 1 is nested 2 deep (tables a and b).
      • The table named by [a.b] is nested 1 deep.
      • Each table of [[a.b]] is nested 2 deep (table a and array b).
      A document containing a value, table or array nested deeper than this limit is reported as a parse error.

      The limit keeps bounded the stack depth needed to parse a document and to serialize the result with toJson() and TomlTable.toToml(). Raising it lets deeper documents parse, but such documents then need a correspondingly larger thread stack to parse and serialize; without one, they fail with a StackOverflowError.

      Parameters:
      maxNestingDepth - The maximum number of tables and arrays, not counting the root table, that may enclose any value, table or array in the document. Must not be negative; with 0, every table and array must be empty and directly in the root table.
      Returns:
      A new set of options with the given maximum nesting depth.
      Throws:
      IllegalArgumentException - If maxNestingDepth is negative.
    • version

      public TomlVersion version()
      The version level to parse at.
      Returns:
      The version level to parse at.
    • maxNestingDepth

      public int maxNestingDepth()
      The maximum nesting depth allowed in a parsed document.
      Returns:
      The maximum number of tables and arrays, not counting the root table, that may enclose any value, table or array in the document.
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object