org.ispheres.shared.objects
Class DigitalObject

java.lang.Object
  extended by org.ispheres.shared.objects.DigitalObject
Direct Known Subclasses:
DatabaseRecord, Image, ShapeElement

public abstract class DigitalObject
extends java.lang.Object

The abstract ISphere object class from which all other classes in the object hierarchy inherit. Each and every digital object available within iSpheres must inherit this class

Author:
Clinton Freeman mochumbo@users.sourceforge.net, Jonathan Mezach

Constructor Summary
DigitalObject(java.util.ArrayList<ISpheresStream> supportedStreams)
          Default constructor.
 
Method Summary
static boolean extendsThis(java.lang.Class theClass)
          Checks if the supplied class extends the digital object.
 java.lang.String getContentType()
           
protected  ISpheresStream getCurrentStream()
           
abstract  void populate(byte[] serialisedObject)
          Populate the object with the data represented in serialisedObject.
 byte[] serialise()
           
 void setCurrentStream(int index)
          This function sets the current stream used to populate and serialise the object to the stream at the nominated index in 'streams'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigitalObject

public DigitalObject(java.util.ArrayList<ISpheresStream> supportedStreams)
Default constructor. Every ISphereObject requires one of these. An object is created by calling this constructor then calling populate() on that object.

Parameters:
supportedStreams - All the streams that can be used to populate and serialise this particular digital object.
Method Detail

getContentType

public final java.lang.String getContentType()
Returns:
The content type of the ISphereDigitalObject as a String. (Pretty much the MIME type of the ISphereDigitalObject).

getCurrentStream

protected final ISpheresStream getCurrentStream()
Returns:
The current stream used for serialising and deserialisng the digital object.

populate

public abstract void populate(byte[] serialisedObject)
                       throws DigitalObjectException
Populate the object with the data represented in serialisedObject. This is the reverse of serialise.

Parameters:
serialisedObject - A serialised object.
Throws:
DigitalObjectException - Thrown when unable to populate the digital object.

serialise

public final byte[] serialise()
                       throws DigitalObjectException
Returns:
A byte[] representation of the object. This should be the equivalent of the bytes that would be saved to a file of this object type. E.g. a jpeg would return a byte[] containing the same bytes that would be saved to a jpeg file on disk.
Throws:
DigitalObjectException - Thrown when unable to serialise the digital object FIXME ***AN ARRAY CAN HAVE A MAXIMUM OF Integer.MAX_VALUE ELEMENTS - this will limit the size of objects we can serialise.

setCurrentStream

public final void setCurrentStream(int index)
This function sets the current stream used to populate and serialise the object to the stream at the nominated index in 'streams'.

Parameters:
index - The index of the stream to use as the current stream.

extendsThis

public static boolean extendsThis(java.lang.Class theClass)
Checks if the supplied class extends the digital object.

Parameters:
theClass - The class to check if it extends digitalObject.
Returns:
True when theClass extends DigitalObject, false otherwise.


Copyright © 2004-2005 The Archaeological Computing Laboratory, University of Sydney. All Rights Reserved.