Package org.apache.pivot.serialization
Class BinarySerializer
- java.lang.Object
-
- org.apache.pivot.serialization.BinarySerializer
-
- All Implemented Interfaces:
Serializer<java.lang.Object>
public class BinarySerializer extends java.lang.Object implements Serializer<java.lang.Object>
Implementation of theSerializer
interface that uses Java's internal serialization mechanism to read and write values. All values in the object hierarchy are required to implementSerializable
.Note that for better security, you should only use BinarySerializer in QueryServlet if you're sure the incoming requests will only come from trusted sources.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CLASS_PARAMETER
static java.lang.String
MIME_TYPE
-
Constructor Summary
Constructors Constructor Description BinarySerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getMIMEType(java.lang.Object object)
Returns the MIME type of the data read and written by this serializer.java.lang.Object
readObject(java.io.InputStream inputStream)
Reads a graph of serialized objects from an input stream.void
writeObject(java.lang.Object object, java.io.OutputStream outputStream)
Writes a graph of serializable objects to an output stream.
-
-
-
Field Detail
-
MIME_TYPE
public static final java.lang.String MIME_TYPE
- See Also:
- Constant Field Values
-
CLASS_PARAMETER
public static final java.lang.String CLASS_PARAMETER
- See Also:
- Constant Field Values
-
-
Method Detail
-
readObject
public java.lang.Object readObject(java.io.InputStream inputStream) throws java.io.IOException, SerializationException
Reads a graph of serialized objects from an input stream.- Specified by:
readObject
in interfaceSerializer<java.lang.Object>
- 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(java.lang.Object object, java.io.OutputStream outputStream) throws java.io.IOException, SerializationException
Writes a graph of serializable objects to an output stream.- Specified by:
writeObject
in interfaceSerializer<java.lang.Object>
- 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
public java.lang.String getMIMEType(java.lang.Object object)
Description copied from interface:Serializer
Returns the MIME type of the data read and written by this serializer.- Specified by:
getMIMEType
in interfaceSerializer<java.lang.Object>
- 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.
-
-