pt.ist.fenixframework.core
Class AbstractDomainObject

Package class diagram package AbstractDomainObject
java.lang.Object
  extended by pt.ist.fenixframework.core.AbstractDomainObject
All Implemented Interfaces:
Serializable, DomainObject
Direct Known Subclasses:
AbstractDomainObjectAdapter, AbstractNode_Base, AbstractNode_Base, AbstractNodeArray_Base, BPlusTree_Base, BPlusTree_Base, BPlusTreeArray_Base, DomainRoot_Base, LinkedList_Base, ListNode_Base, SkipList_Base, SkipListNode_Base

public abstract class AbstractDomainObject
extends Object
implements DomainObject

This is the top-level class for every DomainObject. Each backend should provide a subclass of this class, with a backend-specific implementation of both DomainObject.getExternalId() and getOid(). In this class, they simply throw an UnsupportedOperationException. The method DomainObject.getExternalId() should be used by the user of the framework, whereas the method getOid() should be used by code within the framework. This allows for a more efficient implementation of the object's internal identifier, other than the String type imposed on the external identifier. Additionally, the subclass must also implement ensureOid(), makeSerializedForm(), and AbstractDomainObject.SerializedForm.fromExternalId(String). See their documentation for further explanation.

See Also:
Serialized Form

Nested Class Summary
protected static class AbstractDomainObject.SerializedForm
           
 
Constructor Summary
protected AbstractDomainObject()
          Default, no-arg constructor.
protected AbstractDomainObject(DomainObjectAllocator.OID oid)
          This constructor exists only as part of the allocate-instance protocol and should never be explicitly invoked by the programmer.
 
Method Summary
protected  void ensureOid()
          Set the identifier (oid) of the object that is being created.
 boolean equals(Object obj)
           
 String getExternalId()
           
 Comparable getOid()
          Returns an internal global representation of this object.
 int hashCode()
           
protected  AbstractDomainObject.SerializedForm makeSerializedForm()
          Creates the concrete instance of SerializedForm for this DomainObject.
 String toString()
           
protected  Object writeReplace()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractDomainObject

protected AbstractDomainObject()
Default, no-arg constructor. Calls ensureOid() to set the object's identifier. Every DomainObject constructor (except for the special allocate-instance constructor) should ensure that ensureOid() is called once during object creation.

See Also:
ensureOid()

AbstractDomainObject

protected AbstractDomainObject(DomainObjectAllocator.OID oid)
This constructor exists only as part of the allocate-instance protocol and should never be explicitly invoked by the programmer. Each backend must implement this constructor, and decide how the OID gets restored to the object. Note that the classes modelled in DML are automatically injected with this constructor, which simply delegates the operation to their superclass's constructor. In this class, this constructor is empty. It is here just as a placeholder for this documentation.

Method Detail

getExternalId

public String getExternalId()
Specified by:
getExternalId in interface DomainObject

getOid

public Comparable getOid()
Returns an internal global representation of this object. Although, it can be implemented simply as a call to getExternalId(), this method enables code **within** the framework to leverage on the knowledge of the concrete identifier, thus being more efficient. This method should only be used by code internal to the framework.


ensureOid

protected void ensureOid()
Set the identifier (oid) of the object that is being created. This method is invoked by the no-arg constructor. It is only intented to be invoked from within a constructor (with the exception of AbstractDomainObject(DomainObjectAllocator.OID), which has its own way of restoring the object's id.


hashCode

public final int hashCode()
Overrides:
hashCode in class Object

equals

public final boolean equals(Object obj)
Overrides:
equals in class Object

writeReplace

protected Object writeReplace()
                       throws ObjectStreamException
Throws:
ObjectStreamException

makeSerializedForm

protected AbstractDomainObject.SerializedForm makeSerializedForm()
Creates the concrete instance of SerializedForm for this DomainObject. This method is invoked when serialization of the DomainObject occurs. Final users of this framework should never invoke this method explicitly. Backend developers should provide an implementation for this method in their subclasses of AbstractDomainObject.

Returns:
The corresponding SerializedForm

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.