Package xyz.calcugames.levelz
Class LevelExporter
java.lang.Object
xyz.calcugames.levelz.LevelExporter
Represents a class that exports a LevelZ Level to a file.
-
Field Summary
FieldsModifier and TypeFieldDescriptionWhether to include a section separator in the export.booleanWhether to include data in the export.booleanWhether to include headers in the export.The line separator to use in the export. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull LevelExporterExports the Level to a file.voidwriteToByteArray(byte[] data) Writes to a byte array using the default charset.voidwriteToByteArray(byte[] data, @NotNull Charset charset) Writes to a byte array.voidwriteToFile(@NotNull File file) Writes to a file using the default charset.voidwriteToFile(@NotNull File file, @NotNull Charset charset) Writes to a file.voidwriteToPath(@NotNull Path file) Writes to a file path using the default charset.voidwriteToPath(@NotNull Path file, @NotNull Charset charset) Writes to a file path.voidwriteToStream(@NotNull OutputStream stream) Writes this level to an output stream using the default charset.voidwriteToStream(@NotNull OutputStream stream, @NotNull Charset charset) Writes this level to an output stream.@NotNull StringExports the Level to a string.
-
Field Details
-
includeHeaders
public boolean includeHeadersWhether to include headers in the export. -
includeData
public boolean includeDataWhether to include data in the export. -
fileExtension
Whether to include a section separator in the export. -
lineSeparator
The line separator to use in the export. Default is\n.
-
-
Method Details
-
export
Exports the Level to a file.- Parameters:
level- Level to Export- Returns:
- Level Exporter
-
writeToString
Exports the Level to a string.- Returns:
- Level String
-
writeToByteArray
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 intocharset- Charset to encode bytes with- Throws:
IllegalArgumentException- if the data or charset is null
-
writeToFile
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- Filecharset- Charset to encode bytes with- Throws:
IllegalArgumentException- if the file or charset is null
-
writeToPath
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 Pathcharset- Charset to encode bytes with- Throws:
IllegalArgumentException- if the path or charset is null
-
writeToStream
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 Streamcharset- Charset to encode bytes with- Throws:
IllegalArgumentException- if the stream or charset is null
-