org.apache.pivot.serialization
Class ByteArraySerializer

java.lang.Object
  extended by org.apache.pivot.serialization.ByteArraySerializer
All Implemented Interfaces:
Serializer<byte[]>

public class ByteArraySerializer
extends Object
implements Serializer<byte[]>

Implementation of the Serializer interface that reads and writes a byte array.

See Also:
Serializer

Field Summary
static int BUFFER_SIZE
           
static String MIME_TYPE
           
 
Constructor Summary
ByteArraySerializer()
           
 
Method Summary
 String getMIMEType(byte[] bytes)
          Returns the MIME type of the data read and written by this serializer.
 byte[] readObject(InputStream inputStream)
          Reads a byte array from an input stream.
 void writeObject(byte[] bytes, OutputStream outputStream)
          Writes a byte array to an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIME_TYPE

public static final String MIME_TYPE
See Also:
Constant Field Values

BUFFER_SIZE

public static final int BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

ByteArraySerializer

public ByteArraySerializer()
Method Detail

readObject

public byte[] readObject(InputStream inputStream)
                  throws IOException,
                         SerializationException
Reads a byte array from an input stream.

Specified by:
readObject in interface Serializer<byte[]>
Parameters:
inputStream - The data stream from which the object will be read.
Returns:
The deserialized object.
Throws:
IOException
SerializationException

writeObject

public void writeObject(byte[] bytes,
                        OutputStream outputStream)
                 throws IOException,
                        SerializationException
Writes a byte array to an output stream.

Specified by:
writeObject in interface Serializer<byte[]>
Parameters:
bytes - The object to serialize.
outputStream - The data stream to which the object will be written.
Throws:
IOException
SerializationException

getMIMEType

public String getMIMEType(byte[] bytes)
Description copied from interface: Serializer
Returns the MIME type of the data read and written by this serializer.

Specified by:
getMIMEType in interface Serializer<byte[]>
Parameters:
bytes - 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.