Package org.apache.pivot.serialization
Class ByteArraySerializer
- java.lang.Object
-
- org.apache.pivot.serialization.ByteArraySerializer
-
- All Implemented Interfaces:
Serializer<byte[]>
public class ByteArraySerializer extends java.lang.Object implements Serializer<byte[]>
Implementation of theSerializerinterface that reads and writes a byte array.- See Also:
Serializer
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringMIME_TYPE
-
Constructor Summary
Constructors Constructor Description ByteArraySerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetMIMEType(byte[] bytes)Returns the MIME type of the data read and written by this serializer.byte[]readObject(java.io.InputStream inputStream)Reads a byte array from an input stream.voidwriteObject(byte[] bytes, java.io.OutputStream outputStream)Writes a byte array to an output stream.
-
-
-
Field Detail
-
MIME_TYPE
public static final java.lang.String MIME_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
readObject
public byte[] readObject(java.io.InputStream inputStream) throws java.io.IOException, SerializationExceptionReads a byte array from an input stream.- Specified by:
readObjectin interfaceSerializer<byte[]>- 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
public void writeObject(byte[] bytes, java.io.OutputStream outputStream) throws java.io.IOException, SerializationExceptionWrites a byte array to an output stream.- Specified by:
writeObjectin interfaceSerializer<byte[]>- Parameters:
bytes- 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
public java.lang.String getMIMEType(byte[] bytes)
Description copied from interface:SerializerReturns the MIME type of the data read and written by this serializer.- Specified by:
getMIMETypein interfaceSerializer<byte[]>- Parameters:
bytes- 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.
-
-