Interface DataFormat
-
- All Superinterfaces:
DefaultedRegistryValue
- All Known Subinterfaces:
StringDataFormat
@CatalogedBy(DataFormats.class) public interface DataFormat extends DefaultedRegistryValue
Represents a parser for a particular file format allowing reading and writing a DataContainer to/from a stream of the specific format.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DataContainer
readFrom(InputStream input)
Creates a newDataContainer
from the contents of the givenInputStream
.void
writeTo(OutputStream output, DataView data)
-
Methods inherited from interface org.spongepowered.api.registry.DefaultedRegistryValue
asDefaultedReference, findKey, key
-
-
-
-
Method Detail
-
readFrom
DataContainer readFrom(InputStream input) throws InvalidDataFormatException, IOException
Creates a newDataContainer
from the contents of the givenInputStream
.- Parameters:
input
- The input stream- Returns:
- A data container representing the contents of the input stream
- Throws:
InvalidDataFormatException
- If the data in the stream was not a supported formatIOException
- If there was an error reading from the stream
-
writeTo
void writeTo(OutputStream output, DataView data) throws IOException
- Parameters:
output
- The output stream to write the data todata
- The DataView to write to the stream- Throws:
IOException
- If there was an error writing to the stream
-
-