Package org.apache.pivot.serialization
Interface Serializer<T>
-
- Type Parameters:
T
- The type of data being read and written.
- All Known Implementing Classes:
BinarySerializer
,BufferedImageSerializer
,BXMLSerializer
,ByteArraySerializer
,CSVSerializer
,FileSerializer
,JSONSerializer
,PlainTextSerializer
,PropertiesSerializer
,StringSerializer
,SVGDiagramSerializer
,XMLSerializer
public interface Serializer<T>
Defines an interface for writing objects to and reading objects from a data stream.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
getMIMEType(T object)
Returns the MIME type of the data read and written by this serializer.T
readObject(java.io.InputStream inputStream)
Reads an object from an input stream.void
writeObject(T object, java.io.OutputStream outputStream)
Writes an object to an output stream.
-
-
-
Method Detail
-
readObject
T readObject(java.io.InputStream inputStream) throws java.io.IOException, SerializationException
Reads an object from an input stream.- Parameters:
inputStream
- The data stream from which the object will be read.- Returns:
- The deserialized object.
- Throws:
java.io.IOException
- for any errors accessing or reading the object.SerializationException
- for any formatting errors encountered while deserializing the object.
-
writeObject
void writeObject(T object, java.io.OutputStream outputStream) throws java.io.IOException, SerializationException
Writes an object to an output stream.- Parameters:
object
- The object to serialize.outputStream
- The data stream to which the object will be written.- Throws:
java.io.IOException
- for any errors accessing or reading the object.SerializationException
- for any formatting errors encountered while deserializing the object.
-
getMIMEType
java.lang.String getMIMEType(T object)
Returns the MIME type of the data read and written by this serializer.- Parameters:
object
- If provided, allows the serializer to attach parameters to the returned MIME type containing more detailed information about the data. Ifnull
, the base MIME type is returned.- Returns:
- The MIME type of the current data.
-
-