org.apache.pivot.serialization
Interface Serializer<T>

Type Parameters:
T - The type of data being read and written.
All Known Implementing Classes:
BinarySerializer, BXMLSerializer, ByteArraySerializer, CSVSerializer, FileSerializer, JSONSerializer, PropertiesSerializer, StringSerializer, XMLSerializer

public interface Serializer<T>

Defines an interface for writing objects to and reading objects from a data stream.


Method Summary
 String getMIMEType(T object)
          Returns the MIME type of the data read and written by this serializer.
 T readObject(InputStream inputStream)
          Reads an object from an input stream.
 void writeObject(T object, OutputStream outputStream)
          Writes an object to an output stream.
 

Method Detail

readObject

T readObject(InputStream inputStream)
             throws 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:
IOException
SerializationException

writeObject

void writeObject(T object,
                 OutputStream outputStream)
                 throws 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:
IOException
SerializationException

getMIMEType

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. If null, the base MIME type is returned.