Interface JToml


@NonExtendable public interface JToml
Entry point for JToml
See Also:
  • Method Details

    • jToml

      @Contract("_ -> new") @NotNull static @NotNull JToml jToml(@NotNull @NotNull JTomlOptions options)
      Creates a new JToml instance
      Parameters:
      options - Options to set on the instance
      See Also:
    • jToml

      @Contract(pure=true) @NotNull static @NotNull JToml jToml()
      Provides the default JToml instance
    • readFromString

      @NotNull @NotNull TomlDocument readFromString(@NotNull @NotNull String toml) throws TomlException
      Reads a TOML table from a string
      Parameters:
      toml - A string containing a TOML document
      Throws:
      TomlException - String is not valid TOML
    • read

      @NotNull @NotNull TomlDocument read(@NotNull @NotNull InputStream in) throws TomlException
      Reads a TOML table from a stream
      Parameters:
      in - Stream to read from
      Throws:
      TomlIOException - The underlying stream raised an exception
      TomlException - 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 than UTF-8 may 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 exception
      TomlException - Data is not valid TOML
      See Also:
    • read

      @NotNull default @NotNull TomlDocument read(@NotNull @NotNull Path file) throws TomlException
      Reads a TOML table from the filesystem
      Parameters:
      file - Path to the TOML file
      Throws:
      TomlIOException - The filesystem raised an exception
      TomlException - File is not valid TOML
      See Also:
    • read

      @NotNull default @NotNull TomlDocument read(@NotNull @NotNull File file) throws TomlException
      Reads a TOML table from the filesystem
      Parameters:
      file - Path to the TOML file
      Throws:
      TomlIOException - The filesystem raised an exception
      TomlException - File is not valid TOML
      See Also:
    • writeToString

      @NotNull @NotNull String writeToString(@NotNull @NotNull TomlTable table) throws TomlValueException
      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 data
      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.
      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 than UTF-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 plaintext
      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.
      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 data
      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.
      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 data
      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.
      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
      Serializes the given TOML table to the given type, if an appropriate serializer is present in the classpath. A list of serializers can be found here.
      Parameters:
      type - The type to serialize to
      table - 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 found here.
      Parameters:
      type - The type to convert to
      table - 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 found here.
      Parameters:
      type - The type to deserialize from
      data - 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 found here.
      Parameters:
      type - The type to convert from
      data - The data to convert into a TOML table
      Throws:
      IllegalArgumentException - No deserializer is registered for the given type