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
Modifier and TypeFieldDescriptionWhether to include a section separator in the export.boolean
Whether to include data in the export.boolean
Whether to include headers in the export.The line separator to use in the export. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull LevelExporter
Exports the Level to a file.void
writeToByteArray
(byte[] data) Writes to a byte array using the default charset.void
writeToByteArray
(byte[] data, @NotNull Charset charset) Writes to a byte array.void
writeToFile
(@NotNull File file) Writes to a file using the default charset.void
writeToFile
(@NotNull File file, @NotNull Charset charset) Writes to a file.void
writeToPath
(@NotNull Path file) Writes to a file path using the default charset.void
writeToPath
(@NotNull Path file, @NotNull Charset charset) Writes to a file path.void
writeToStream
(@NotNull OutputStream stream) Writes this level to an output stream using the default charset.void
writeToStream
(@NotNull OutputStream stream, @NotNull Charset charset) Writes this level to an output stream.@NotNull String
Exports 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
-