Package org.tomlj
Class TomlParseOptions
java.lang.Object
org.tomlj.TomlParseOptions
Options controlling how a TOML document is parsed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default maximum nesting depth: 128. -
Method Summary
Modifier and TypeMethodDescriptionstatic TomlParseOptionsdefaults()The default parse options:TomlVersion.LATEST, with a maximum nesting depth of 128, keeping the text of the document parsed so that it can be written back as it was read.booleaninthashCode()intThe maximum nesting depth allowed in a parsed document.booleanWhether a parse result keeps the source text of the document it was read from.static TomlParseOptionsThe default parse options, but keeping no source text: the same asdefaults().withoutSource().toString()version()The version level to parse at.withMaxNestingDepth(int maxNestingDepth) Create a copy of these options that allows a different maximum nesting depth.Create a copy of these options that keeps no source text.withVersion(TomlVersion version) Create a copy of these options that parses at a different specification version.
-
Field Details
-
DEFAULT_MAX_NESTING_DEPTH
public static final int DEFAULT_MAX_NESTING_DEPTHThe default maximum nesting depth: 128.- See Also:
-
-
Method Details
-
defaults
The default parse options:TomlVersion.LATEST, with a maximum nesting depth of 128, keeping the text of the document parsed so that it can be written back as it was read.- Returns:
- The default parse options.
-
sourceless
The default parse options, but keeping no source text: the same asdefaults().withoutSource().- Returns:
- The default parse options, keeping no source text.
- See Also:
-
withVersion
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
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 integer1is nested 2 deep (the outer and inner arrays). - In
a.b.c = 1the integer1is nested 2 deep (tablesaandb). - The table named by
[a.b]is nested 1 deep. - Each table of
[[a.b]]is nested 2 deep (tableaand arrayb).
The limit keeps bounded the stack depth needed to parse a document and to serialize the result with
toJson()andTomlTable.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 aStackOverflowError.- 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; with0, 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- IfmaxNestingDepthis negative.
- In
-
withoutSource
Create a copy of these options that keeps no source text.By default a parse result keeps the text it was parsed from, and where each line it accepted sits in that text, so that
TomlTable.toToml()can write the document back as it was read. Parsing without the source takes less memory, andtoToml()then writes the document in the default style.- Returns:
- A new set of options that keeps no source text.
-
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:
-
retainsSource
public boolean retainsSource()Whether a parse result keeps the source text of the document it was read from.- Returns:
trueunless these options came fromsourceless()orwithoutSource().- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-