Package org.jcsp.net
Class SerializedObject
- java.lang.Object
-
- org.jcsp.net.SerializedObject
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
class SerializedObject extends java.lang.Object implements java.io.Externalizable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
SerializedObject.AccesibleByteArrayOutputStream
This class exists purely for performance reasons.private class
SerializedObject.BasicInputStreamFactory
private static class
SerializedObject.ExtClass
This class exists because the main class cannot have a no-arg constructor as required by externalizable.static interface
SerializedObject.InputStreamFactory
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
objectToString
private byte[]
serializedData
-
Constructor Summary
Constructors Constructor Description SerializedObject(byte[] data, java.lang.String objectToString)
A private constructor used during the deserialization process of this object.SerializedObject(java.lang.Object obj, boolean storeToString)
This is the public used constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get()
java.lang.Object
get(SerializedObject.InputStreamFactory factory)
java.lang.String
getObjectToString()
byte[]
getSerializedData()
void
readExternal(java.io.ObjectInput in)
void
writeExternal(java.io.ObjectOutput out)
java.lang.Object
writeReplace()
-
-
-
Constructor Detail
-
SerializedObject
public SerializedObject(java.lang.Object obj, boolean storeToString) throws java.io.NotSerializableException, java.io.IOException
This is the public used constructor. It takes an object and attempts to serialize it.- Throws:
java.io.NotSerializableException
- If obj is not Serializable.java.io.IOException
- if an IO error occurs during Serialization, should not happen unless there is a bug.
-
SerializedObject
SerializedObject(byte[] data, java.lang.String objectToString)
A private constructor used during the deserialization process of this object. Externalizable objects require a no-arg constructor so a replacement object is serialized in this object's place. On deserialization, this object is reconstructed using this constructor.- Parameters:
data
- a byte[] containing the serialized data of the object that this object is holding.objectToString
- The toString value of the stored object.
-
-
Method Detail
-
getSerializedData
public byte[] getSerializedData()
-
get
public java.lang.Object get() throws java.lang.ClassNotFoundException, java.io.IOException
- Throws:
java.lang.ClassNotFoundException
java.io.IOException
-
get
public java.lang.Object get(SerializedObject.InputStreamFactory factory) throws java.lang.ClassNotFoundException, java.io.IOException
- Throws:
java.lang.ClassNotFoundException
java.io.IOException
-
getObjectToString
public java.lang.String getObjectToString()
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
writeReplace
public java.lang.Object writeReplace() throws java.io.ObjectStreamException
- Throws:
java.io.ObjectStreamException
-
-