Class LevelExporter

java.lang.Object
xyz.calcugames.levelz.LevelExporter

public final class LevelExporter extends Object
Represents a class that exports a LevelZ Level to a file.
  • Field Details

    • includeHeaders

      public boolean includeHeaders
      Whether to include headers in the export.
    • includeData

      public boolean includeData
      Whether to include data in the export.
    • fileExtension

      public String fileExtension
      Whether to include a section separator in the export.
    • lineSeparator

      public String lineSeparator
      The line separator to use in the export. Default is \n.
  • Method Details

    • export

      @NotNull public static @NotNull LevelExporter export(@NotNull @NotNull Level level)
      Exports the Level to a file.
      Parameters:
      level - Level to Export
      Returns:
      Level Exporter
    • writeToString

      @NotNull public @NotNull String writeToString()
      Exports the Level to a string.
      Returns:
      Level String
    • writeToByteArray

      public void writeToByteArray(byte[] data) throws IllegalArgumentException

      Writes to a byte array using the default charset.

      The exporter will only write to the byte buffer if there is enough space, stopping if the length if too small.

      Parameters:
      data - Byte Array to encode into
      Throws:
      IllegalArgumentException - if the data is null
    • writeToByteArray

      public void writeToByteArray(byte[] data, @NotNull @NotNull Charset charset) throws IllegalArgumentException

      Writes to a byte array.

      The exporter will only write to the byte buffer if there is enough space, stopping if the length if too small.

      Parameters:
      data - Byte Array to encode into
      charset - Charset to encode bytes with
      Throws:
      IllegalArgumentException - if the data or charset is null
    • writeToFile

      public void writeToFile(@NotNull @NotNull File file) throws IllegalArgumentException
      Writes to a file using the default charset. This will create the file if it does not exist.
      Parameters:
      file - File
      Throws:
      IllegalArgumentException - if the file is null
    • writeToFile

      public void writeToFile(@NotNull @NotNull File file, @NotNull @NotNull Charset charset) throws IllegalArgumentException
      Writes to a file. This will create the file if it does not exist.
      Parameters:
      file - File
      charset - Charset to encode bytes with
      Throws:
      IllegalArgumentException - if the file or charset is null
    • writeToPath

      public void writeToPath(@NotNull @NotNull Path file) throws IllegalArgumentException
      Writes to a file path using the default charset.
      Parameters:
      file - File Path
      Throws:
      IllegalArgumentException - if the path is null
    • writeToPath

      public void writeToPath(@NotNull @NotNull Path file, @NotNull @NotNull Charset charset) throws IllegalArgumentException
      Writes to a file path.
      Parameters:
      file - File Path
      charset - Charset to encode bytes with
      Throws:
      IllegalArgumentException - if the path or charset is null
    • writeToStream

      public void writeToStream(@NotNull @NotNull OutputStream stream) throws IllegalArgumentException
      Writes this level to an output stream using the default charset.
      Parameters:
      stream - Output Stream
      Throws:
      IllegalArgumentException - if the stream is null
    • writeToStream

      public void writeToStream(@NotNull @NotNull OutputStream stream, @NotNull @NotNull Charset charset) throws IllegalArgumentException
      Writes this level to an output stream.
      Parameters:
      stream - Output Stream
      charset - Charset to encode bytes with
      Throws:
      IllegalArgumentException - if the stream or charset is null