weka.core
Class SerializedObject

java.lang.Object
  extended byweka.core.SerializedObject
All Implemented Interfaces:
java.io.Serializable

public class SerializedObject
extends java.lang.Object
implements java.io.Serializable

Class for storing an object in serialized form in memory. It can be used to make deep copies of objects, and also allows compression to conserve memory.

Version:
$Revision: 1.7 $
Author:
Richard Kirkby (rbk1@cs.waikato.ac.nz)
See Also:
Serialized Form

Field Summary
private  boolean m_isCompressed
          Whether or not the object is compressed.
private  byte[] m_storedObjectArray
          The array storing the object.
 
Constructor Summary
SerializedObject(java.lang.Object toStore)
          Creates a new serialized object (without compression).
SerializedObject(java.lang.Object toStore, boolean compress)
          Creates a new serialized object.
 
Method Summary
 boolean equals(java.lang.Object compareTo)
           
 java.lang.Object getObject()
          Returns a serialized object.
 int hashCode()
          Returns a hashcode for this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_storedObjectArray

private byte[] m_storedObjectArray
The array storing the object.


m_isCompressed

private boolean m_isCompressed
Whether or not the object is compressed.

Constructor Detail

SerializedObject

public SerializedObject(java.lang.Object toStore)
                 throws java.lang.Exception
Creates a new serialized object (without compression).

Parameters:
toStore - the object to store
Throws:
java.lang.Exception - if the object couldn't be serialized

SerializedObject

public SerializedObject(java.lang.Object toStore,
                        boolean compress)
                 throws java.lang.Exception
Creates a new serialized object.

Parameters:
toStore - the object to store
compress - whether or not to use compression
Throws:
java.lang.Exception - if the object couldn't be serialized
Method Detail

equals

public final boolean equals(java.lang.Object compareTo)

hashCode

public int hashCode()
Returns a hashcode for this object.

Returns:
the hashcode

getObject

public java.lang.Object getObject()
Returns a serialized object.

Returns:
the restored object
Throws:
java.lang.Exception - if the object couldn't be restored