Interface TomlValue
- All Superinterfaces:
TomlElement
A table or array is itself the value, so a TomlTable or TomlArray read from a document is also a
TomlValue. The unattached comments written inside it are among its TomlTable.elements() or
TomlArray.elements(). A value never carries comments of its own: the comments written around it belong to the
entry that holds it, read through TomlEntry.comments().
-
Method Summary
Modifier and TypeMethodDescriptionstatic TomlValuebinary(long value) An integer to be written in binary, as0b1010; seehex(long).get()Get the value.default TomlArraygetArray()Get this value as an array.default booleanGet this value as a boolean.default doubleGet this value as a double.default LocalDateGet this value as a local date.default LocalDateTimeGet this value as a local date-time.default LocalTimeGet this value as a local time.default longgetLong()Get this value as a long.default OffsetDateTimeGet this value as an offset date-time.default StringGet this value as a string.default TomlTablegetTable()Get this value as a table.static TomlValuegrouped(long value) An integer to be written in decimal with its digits grouped in threes, as1_000_000; seehex(long).static TomlValuehex(long value) An integer to be written in hexadecimal with uppercase digits, as0xFF.static TomlValuehexLowercase(long value) An integer to be written in hexadecimal with lowercase digits, as0xff; seehex(long).default booleanisArray()trueif this value is an array.default booleantrueif this value is a boolean.default booleanisDouble()trueif this value is a double.default booleantrueif this value is a local date.default booleantrueif this value is a local date-time.default booleantrueif this value is a local time.default booleanisLong()trueif this value is a long.default booleantrueif this value is an offset date-time.default booleanisString()trueif this value is a string.default booleanisTable()trueif this value is a table.static TomlValueA string to be written as a literal string, between apostrophes with nothing escaped, as'C:\Users'; seehex(long).static TomlValuemultilineLiteral(String value) A string to be written as a multi-line literal string, between triple apostrophes with nothing escaped, its newlines written as line breaks; seehex(long).static TomlValueoctal(long value) An integer to be written in octal, as0o755; seehex(long).static TomlValueParse the text of one value, written as it is after the=of akey = valueline, in the latest version of TOML.static TomlValueparse(String text, TomlVersion version) Parse the text of one value, written as it is after the=of akey = valueline.Methods inherited from interface org.tomlj.TomlElement
position
-
Method Details
-
parse
Parse the text of one value, written as it is after the=of akey = valueline, in the latest version of TOML.- Parameters:
text- The value, e.g.0xFF,'C:\path'or{ a = 1 }.- Returns:
- The value, which keeps the notation it was written in; see
parse(String, TomlVersion). - Throws:
NullPointerException- Iftextisnull.IllegalArgumentException- Iftextis not one TOML value.
-
parse
Parse the text of one value, written as it is after the=of akey = valueline.The value keeps the notation it was written in. Stored in a table or an array through the editing API, it is written with the text it was parsed from, as a value read from a document is, unless the document is written keeping nothing (
TomlWriteOptions.Keep.NOTHING); an inline table is written as an inline table, and an array of tables as an array, rather than under[x]or[[x]]headers. Text that only TOML 1.1.0 allows is not written for TOML 1.0.0; seeTomlWriteOptions.withVersion(TomlVersion).A comment or a line break before or after the value is rejected. A comment inside an inline table or an array is part of the value and is kept.
- Parameters:
text- The value, e.g.0xFF,'C:\path'or{ a = 1 }.version- The version of TOML the value is written in.- Returns:
- The value.
- Throws:
NullPointerException- Iftextorversionisnull.IllegalArgumentException- Iftextis not one TOML value.
-
hex
An integer to be written in hexadecimal with uppercase digits, as0xFF.The value carries the notation with it: stored in a table or an array through the editing API, it is written in that notation unless the document is written keeping nothing (
TomlWriteOptions.Keep.NOTHING).parse(String)gives a value any notation TOML has.- Parameters:
value- The integer.- Returns:
- The value.
- Throws:
IllegalArgumentException- Ifvalueis negative, since TOML writes no sign before0x.- See Also:
-
hexLowercase
An integer to be written in hexadecimal with lowercase digits, as0xff; seehex(long).- Parameters:
value- The integer.- Returns:
- The value.
- Throws:
IllegalArgumentException- Ifvalueis negative, since TOML writes no sign before0x.
-
octal
An integer to be written in octal, as0o755; seehex(long).- Parameters:
value- The integer.- Returns:
- The value.
- Throws:
IllegalArgumentException- Ifvalueis negative, since TOML writes no sign before0o.
-
binary
An integer to be written in binary, as0b1010; seehex(long).- Parameters:
value- The integer.- Returns:
- The value.
- Throws:
IllegalArgumentException- Ifvalueis negative, since TOML writes no sign before0b.
-
grouped
An integer to be written in decimal with its digits grouped in threes, as1_000_000; seehex(long).- Parameters:
value- The integer.- Returns:
- The value.
-
literal
A string to be written as a literal string, between apostrophes with nothing escaped, as'C:\Users'; seehex(long).- Parameters:
value- The string.- Returns:
- The value.
- Throws:
NullPointerException- Ifvalueisnull.IllegalArgumentException- Ifvalueholds an apostrophe, a newline or a control character other than tab, none of which a literal string can hold, or an unpaired surrogate.
-
multilineLiteral
A string to be written as a multi-line literal string, between triple apostrophes with nothing escaped, its newlines written as line breaks; seehex(long).- Parameters:
value- The string.- Returns:
- The value.
- Throws:
NullPointerException- Ifvalueisnull.IllegalArgumentException- Ifvalueholds three apostrophes in a row, or a control character other than tab and newline, none of which a multi-line literal string can hold, or an unpaired surrogate.
-
get
Object get()Get the value. -
isString
default boolean isString()trueif this value is a string.- Returns:
trueif this value is a string.
-
getString
Get this value as a string.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not a string.
-
isLong
default boolean isLong()trueif this value is a long.- Returns:
trueif this value is a long.
-
getLong
default long getLong()Get this value as a long.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not a long.
-
isDouble
default boolean isDouble()trueif this value is a double.- Returns:
trueif this value is a double.
-
getDouble
default double getDouble()Get this value as a double.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not a double.
-
isBoolean
default boolean isBoolean()trueif this value is a boolean.- Returns:
trueif this value is a boolean.
-
getBoolean
default boolean getBoolean()Get this value as a boolean.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not a boolean.
-
isOffsetDateTime
default boolean isOffsetDateTime()trueif this value is an offset date-time.- Returns:
trueif this value is an offset date-time.
-
getOffsetDateTime
Get this value as an offset date-time.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not an offset date-time.
-
isLocalDateTime
default boolean isLocalDateTime()trueif this value is a local date-time.- Returns:
trueif this value is a local date-time.
-
getLocalDateTime
Get this value as a local date-time.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not a local date-time.
-
isLocalDate
default boolean isLocalDate()trueif this value is a local date.- Returns:
trueif this value is a local date.
-
getLocalDate
Get this value as a local date.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not a local date.
-
isLocalTime
default boolean isLocalTime()trueif this value is a local time.- Returns:
trueif this value is a local time.
-
getLocalTime
Get this value as a local time.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not a local time.
-
isArray
default boolean isArray()trueif this value is an array.- Returns:
trueif this value is an array.
-
getArray
Get this value as an array.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not an array.
-
isTable
default boolean isTable()trueif this value is a table.- Returns:
trueif this value is a table.
-
getTable
Get this value as a table.- Returns:
- The value.
- Throws:
TomlInvalidTypeException- If the value is not a table.
-