Package io.github.wasabithumb.jtoml
Interface JToml
@NonExtendable
public interface JToml
Entry point for JToml
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> @NotNull TomlTabledeserialize(@NotNull Class<T> type, T data) Deprecated.<T> TConverts the given TOML table to the given type, if an appropriate serializer is present in the classpath.static @NotNull JTomljToml()Provides the default JToml instancestatic @NotNull JTomljToml(@NotNull JTomlOptions options) Creates a new JToml instancedefault @NotNull TomlDocumentReads a TOML table from the filesystem@NotNull TomlDocumentread(@NotNull InputStream in) Reads a TOML table from a stream@NotNull TomlDocumentReads a TOML table from a reader.default @NotNull TomlDocumentReads a TOML table from the filesystem@NotNull TomlDocumentreadFromString(@NotNull String toml) Reads a TOML table from a stringdefault <T> TDeprecated.<T> @NotNull TomlTableConverts the given type to a TOML table, if an appropriate deserializer is present in the classpath.default voidWrites a TOML table to a filevoidwrite(@NotNull OutputStream out, @NotNull TomlTable table) Writes a TOML table to a streamvoidWrites a TOML table to a writer.default voidWrites a TOML table to a file@NotNull StringwriteToString(@NotNull TomlTable table) Writes a TOML table to a string
-
Method Details
-
jToml
Creates a new JToml instance- Parameters:
options- Options to set on the instance- See Also:
-
jToml
Provides the default JToml instance -
readFromString
Reads a TOML table from a string- Parameters:
toml- A string containing a TOML document- Throws:
TomlException- String is not valid TOML
-
read
Reads a TOML table from a stream- Parameters:
in- Stream to read from- Throws:
TomlIOException- The underlying stream raised an exceptionTomlException- Data is not valid TOML
-
read
@AvailableSince("0.3.0") @NotNull @NotNull TomlDocument read(@NotNull @NotNull Reader reader) throws TomlException Reads a TOML table from a reader. A reader that is configured to use any encoding other thanUTF-8may fail to read some valid TOML documents, so this method should be used with care.- Parameters:
reader- Reader to read from- Throws:
TomlIOException- The underlying reader raised an exceptionTomlException- Data is not valid TOML- See Also:
-
read
Reads a TOML table from the filesystem- Parameters:
file- Path to the TOML file- Throws:
TomlIOException- The filesystem raised an exceptionTomlException- File is not valid TOML- See Also:
-
read
Reads a TOML table from the filesystem- Parameters:
file- Path to the TOML file- Throws:
TomlIOException- The filesystem raised an exceptionTomlException- File is not valid TOML- See Also:
-
writeToString
Writes a TOML table to a string- Parameters:
table- Table to write- Throws:
TomlValueException- The TOML spec does not allow for lossless serialization of the table data. See exception docs for more details.
-
write
void write(@NotNull @NotNull OutputStream out, @NotNull @NotNull TomlTable table) throws TomlValueException, TomlIOException Writes a TOML table to a stream- Parameters:
out- Stream to receive the UTF-8 encoded TOML datatable- Table to write- Throws:
TomlValueException- The TOML spec does not allow for lossless serialization of the table data. See exception docs for more details.TomlIOException- The underlying stream raised an exception
-
write
@AvailableSince("0.3.0") void write(@NotNull @NotNull Writer writer, @NotNull @NotNull TomlTable table) throws TomlValueException, TomlIOException Writes a TOML table to a writer. If the writer is configured to use any encoding other thanUTF-8, this may produce documents which are not considered valid by the TOML spec. Hence, this method should be used with care.- Parameters:
writer- Writer to receive the TOML plaintexttable- Table to write- Throws:
TomlValueException- The TOML spec does not allow for lossless serialization of the table data. See exception docs for more details.TomlIOException- The underlying writer raised an exception
-
write
default void write(@NotNull @NotNull Path file, @NotNull @NotNull TomlTable table) throws TomlValueException, TomlIOException Writes a TOML table to a file- Parameters:
file- Path of the file to receive the UTF-8 encoded TOML datatable- Table to write- Throws:
TomlValueException- The TOML spec does not allow for lossless serialization of the table data. See exception docs for more details.TomlIOException- The underlying filesystem raised an exception- See Also:
-
write
default void write(@NotNull @NotNull File file, @NotNull @NotNull TomlTable table) throws TomlValueException, TomlIOException Writes a TOML table to a file- Parameters:
file- Path of the file to receive the UTF-8 encoded TOML datatable- Table to write- Throws:
TomlValueException- The TOML spec does not allow for lossless serialization of the table data. See exception docs for more details.TomlIOException- The underlying filesystem raised an exception- See Also:
-
serialize
@Deprecated @NotNull default <T> T serialize(@NotNull @NotNull Class<T> type, @NotNull @NotNull TomlTable table) throws IllegalArgumentException Deprecated.Serializes the given TOML table to the given type, if an appropriate serializer is present in the classpath. A list of serializers can be foundhere.- Parameters:
type- The type to serialize totable- The table to serialize- Throws:
IllegalArgumentException- No serializer is registered for the given type
-
fromToml
@AvailableSince("1.2.1") @NotNull <T> T fromToml(@NotNull @NotNull Class<T> type, @NotNull @NotNull TomlTable table) throws IllegalArgumentException Converts the given TOML table to the given type, if an appropriate serializer is present in the classpath. A list of serializers can be foundhere.- Parameters:
type- The type to convert totable- The table to convert- Throws:
IllegalArgumentException- No serializer is registered for the given type
-
deserialize
@Deprecated @NotNull default <T> @NotNull TomlTable deserialize(@NotNull @NotNull Class<T> type, @NotNull T data) throws IllegalArgumentException Deprecated.Deserializes a given TOML table from the given type, if an appropriate deserializer is present in the classpath. A list of serializers can be foundhere.- Parameters:
type- The type to deserialize fromdata- The data to deserialize into a TOML table- Throws:
IllegalArgumentException- No deserializer is registered for the given type
-
toToml
@AvailableSince("1.2.1") @NotNull <T> @NotNull TomlTable toToml(@NotNull @NotNull Class<T> type, @NotNull T data) throws IllegalArgumentException Converts the given type to a TOML table, if an appropriate deserializer is present in the classpath. A list of serializers can be foundhere.- Parameters:
type- The type to convert fromdata- The data to convert into a TOML table- Throws:
IllegalArgumentException- No deserializer is registered for the given type
-
toToml(Class, Object)