weka.core
Class SerializedObject

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

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

This class stores an object serialized in memory. It allows compression, to be used to conserve memory (for example, when storing large strings in memory), or can be used as a mechanism for deep copying objects.

Version:
$Revision: 1.1 $
Author:
Len Trigg ([email protected])
See Also:
Serialized Form

Constructor Summary
SerializedObject(java.lang.Object obj)
          Serializes the supplied object into a byte array without compression.
SerializedObject(java.lang.Object obj, boolean compress)
          Serializes the supplied object into a byte array.
 
Method Summary
 boolean equals(java.lang.Object other)
          Compares this object with another for equality.
 java.lang.Object getObject()
          Gets the object stored in this SerializedObject.
 int hashCode()
          Returns a hashcode for this object.
static void main(java.lang.String[] args)
          Test routine, reads an arff file from stdin and measures memory usage (the arff file should have long string attribute values)
static void main2(java.lang.String[] args)
          Test routine, reads text from stdin and measures memory usage
 java.lang.String toString()
          Returns a text representation of the state of this object.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SerializedObject

public SerializedObject(java.lang.Object obj)
                 throws java.lang.Exception
Serializes the supplied object into a byte array without compression.

Parameters:
obj - the Object to serialize.
Throws:
java.lang.Exception - if the object is not Serializable.

SerializedObject

public SerializedObject(java.lang.Object obj,
                        boolean compress)
                 throws java.lang.Exception
Serializes the supplied object into a byte array.

Parameters:
obj - the Object to serialize.
compress - true if the object should be stored compressed.
Throws:
java.lang.Exception - if the object is not Serializable.
Method Detail

getObject

public java.lang.Object getObject()
Gets the object stored in this SerializedObject. The object returned will be a deep copy of the original stored object.

Returns:
the deserialized Object.

equals

public final boolean equals(java.lang.Object other)
Compares this object with another for equality.

Overrides:
equals in class java.lang.Object
Parameters:
other - the other Object.
Returns:
true if the objects are equal.

hashCode

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

Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode for this object.

toString

public java.lang.String toString()
Returns a text representation of the state of this object.

Overrides:
toString in class java.lang.Object
Returns:
a String representing this object.

main2

public static void main2(java.lang.String[] args)
Test routine, reads text from stdin and measures memory usage


main

public static void main(java.lang.String[] args)
Test routine, reads an arff file from stdin and measures memory usage (the arff file should have long string attribute values)