Package org.jcsp.net.dynamic
Class SerializedData
java.lang.Object
org.jcsp.net.dynamic.SerializedData
- All Implemented Interfaces:
Externalizable
,Serializable
Serialized form of an object as as part of a
DynamicClassLoaderMessage
. The object is
serialized to a byte array for transfer to another node. This will allow the message to be
deserialized to obtain the JFTP reference even if the class held here is not available. When the
relevant class has been loaded the data from the byte array can be deserialized.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
This class exists purely for performance reasons.private class
Implementation of theInputStreamFactory
to create aObjectInputStream
.private static class
This class exists because the main class cannot have a no-arg constructor as required by externalizable.static interface
Factory for creating object input streams. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The string representation of the object.private byte[]
The binary form of the object in this message. -
Constructor Summary
ConstructorsConstructorDescriptionSerializedData
(byte[] data, String objectToString) A private constructor used during the deserialization process of this object.SerializedData
(Object obj, boolean storeToString) This is the public used constructor. -
Method Summary
Modifier and TypeMethodDescriptionget()
Deserializes the object from the byte[] array and returns it.get
(SerializedData.InputStreamFactory factory) Deserializes the object from the byte[] array and returns it.Returns the string form of an object.byte[]
Returns the binary serialized object.void
void
Replaces this object with another during serialization.
-
Field Details
-
serializedData
private byte[] serializedDataThe binary form of the object in this message. -
objectToString
The string representation of the object.
-
-
Constructor Details
-
SerializedData
public SerializedData(Object obj, boolean storeToString) throws NotSerializableException, IOException This is the public used constructor. It takes an object and attempts to serialize it.- Parameters:
obj
- the Object to Serialize.storeToString
- iftrue
will create a string representation of the serialized object.- Throws:
NotSerializableException
- If obj is not Serializable.IOException
- if an IO error occurs during Serialization, should not happen unless there is a bug.
-
SerializedData
SerializedData(byte[] data, 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 Details
-
getSerializedData
public byte[] getSerializedData()Returns the binary serialized object. -
get
Deserializes the object from the byte[] array and returns it.- Throws:
ClassNotFoundException
- if the class is not available locally and should be requested.IOException
- if there is a problem with the stream.
-
get
public Object get(SerializedData.InputStreamFactory factory) throws ClassNotFoundException, IOException Deserializes the object from the byte[] array and returns it.- Parameters:
factory
- the factory for creating the input stream.- Throws:
ClassNotFoundException
- if the class is not available locally and should be requested.IOException
- if there is a problem with the stream.
-
getObjectToString
Returns the string form of an object. -
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeReplace
Replaces this object with another during serialization.- Returns:
- the replacement.
- Throws:
ObjectStreamException
-