messif.objects
Class AbstractObject

java.lang.Object
  extended by messif.objects.UniqueID
      extended by messif.objects.AbstractObject
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<UniqueID>, Clearable
Direct Known Subclasses:
LocalAbstractObject, NoDataObject

public abstract class AbstractObject
extends UniqueID
implements java.io.Serializable, Clearable, java.lang.Cloneable

The abstract piece of data that the MESSI Framework works with. This is the top-most class of the object hierarchy.

See Also:
LocalAbstractObject, NoDataObject, Serialized Form

Constructor Summary
protected AbstractObject()
          Creates a new instance of AbstractObject.
protected AbstractObject(AbstractObject source)
          Creates a new instance of AbstractObject.
protected AbstractObject(AbstractObjectKey objectKey)
          Creates a new instance of AbstractObject.
protected AbstractObject(BinaryInput input, BinarySerializator serializator)
          Creates a new instance of AbstractObject loaded from binary input.
protected AbstractObject(java.lang.String locatorURI)
          Creates a new instance of AbstractObject.
 
Method Summary
protected  int binarySerialize(BinaryOutput output, BinarySerializator serializator)
          Binary-serialize this object into the output.
 void clearSurplusData()
          Clear non-messif data stored in this object.
 AbstractObject clone()
          Creates and returns a shallow copy of this object.
 AbstractObject clone(AbstractObjectKey objectKey)
          Creates and returns a copy of this object with changed locatorURI.
protected  int getBinarySize(BinarySerializator serializator)
          Returns the exact size of the binary-serialized version of this object in bytes.
 java.lang.String getLocatorURI()
          Returns the locator URI of this object.
 NoDataObject getNoDataObject()
          Returns this object as no-data object.
 UniqueID getObjectID()
          Returns the ID of this object
 AbstractObjectKey getObjectKey()
          Returns the object key.
 void setObjectKey(AbstractObjectKey objectKey)
          Set the object key
 java.lang.String toString()
          Returns a string representation of this abstract object.
 
Methods inherited from class messif.objects.UniqueID
compareTo, equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractObject

protected AbstractObject()
Creates a new instance of AbstractObject. A new unique object ID is generated and the object's key is set to null.


AbstractObject

protected AbstractObject(AbstractObjectKey objectKey)
Creates a new instance of AbstractObject. A new unique object ID is generated and the object's key is set to the specified key.

Parameters:
objectKey - the key to be associated with this object

AbstractObject

protected AbstractObject(java.lang.String locatorURI)
Creates a new instance of AbstractObject. A new unique object ID is generated and a new AbstractObjectKey is generated for the specified locatorURI.

Parameters:
locatorURI - the locator URI for the new object

AbstractObject

protected AbstractObject(AbstractObject source)
Creates a new instance of AbstractObject. The object ID and key are copied from the source object. If the key is not AbstractObjectKey, the key is replaced with an instance of AbstractObjectKey that copies the locator URI.

Parameters:
source - the object from which to copy the ID

AbstractObject

protected AbstractObject(BinaryInput input,
                         BinarySerializator serializator)
                  throws java.io.IOException
Creates a new instance of AbstractObject loaded from binary input.

Parameters:
input - the input to read the AbstractObject from
serializator - the serializator used to write objects
Throws:
java.io.IOException - if there was an I/O error reading from the input
Method Detail

getObjectID

public UniqueID getObjectID()
Returns the ID of this object

Returns:
the ID of this object

getObjectKey

public AbstractObjectKey getObjectKey()
Returns the object key.

Returns:
the object key

setObjectKey

public void setObjectKey(AbstractObjectKey objectKey)
Set the object key

Parameters:
objectKey - the new object key

getLocatorURI

public java.lang.String getLocatorURI()
Returns the locator URI of this object.

Returns:
the locator URI of this object

clearSurplusData

public void clearSurplusData()
Clear non-messif data stored in this object. That is, the object key is changed to AbstractObjectKey if not null. The transformation only preserves the locator URI, all additional information is lost.

Specified by:
clearSurplusData in interface Clearable

getNoDataObject

public NoDataObject getNoDataObject()
Returns this object as no-data object. Only the object key and ID is preserved, any internal or supplemental data are not copied.

Returns:
this object as NoDataObject

clone

public AbstractObject clone()
                     throws java.lang.CloneNotSupportedException
Creates and returns a shallow copy of this object. The precise meaning of "copy" may depend on the class of the object.

Overrides:
clone in class UniqueID
Returns:
a clone of this instance
Throws:
java.lang.CloneNotSupportedException - if the object's class does not support clonning or there was an error

clone

public final AbstractObject clone(AbstractObjectKey objectKey)
                           throws java.lang.CloneNotSupportedException
Creates and returns a copy of this object with changed locatorURI. The precise meaning of "copy" may depend on the class of the object.

Parameters:
objectKey - new object key
Returns:
a clone of this instance
Throws:
java.lang.CloneNotSupportedException - if the object's class does not support clonning or there was an error

toString

public java.lang.String toString()
Returns a string representation of this abstract object. Basically, this method returns the object type plus object locator (or ID if locator is null) in brackets.

Overrides:
toString in class UniqueID
Returns:
a string representation of this abstract object

binarySerialize

protected int binarySerialize(BinaryOutput output,
                              BinarySerializator serializator)
                       throws java.io.IOException
Binary-serialize this object into the output.

Overrides:
binarySerialize in class UniqueID
Parameters:
output - the output that this object is binary-serialized into
serializator - the serializator used to write objects
Returns:
the number of bytes actually written
Throws:
java.io.IOException - if there was an I/O error during serialization

getBinarySize

protected int getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.

Overrides:
getBinarySize in class UniqueID
Parameters:
serializator - the serializator used to write objects
Returns:
size of the binary-serialized version of this object