org.datamanager.kernel
Class CachingProxyEntity

java.lang.Object
  |
  +--org.datamanager.kernel.Entity
        |
        +--org.datamanager.kernel.CachingProxyEntity
All Implemented Interfaces:
EventGenerator, Serializable

public class CachingProxyEntity
extends Entity

Entities that proxy for and lazily cache the information of other Entities. The implicit assumption is that these underlying Entities will not be modified through any other mechanism but through their enclosing CachingProxyEntitys.

See Also:
Serialized Form

Constructor Summary
protected CachingProxyEntity(Entity proxiedEntity)
          Creates a new CachingProxyEntity proxying for the given Entity.
 
Method Summary
protected  void addBase(org.datamanager.kernel.Identifier base)
          Add an Entity to the list of bases.
 void attach(Entity attribute)
          Attach the given Entity as an attribute.
 void attach(org.datamanager.kernel.Identifier attribute)
          Attach the Entity with the given Identifier as an attribute.
 void detach(Entity attribute)
          Detach the given Entity.
 void detach(org.datamanager.kernel.Identifier attribute)
          Detach the Entity with the given Identifier.
 void finalize()
           
 Entity[] getAttributes(EntityConstraint constraint)
          Request a constrained set of all entities linked to the Entity.
 Entity[] getBases(EntityConstraint constraint)
          Request a constrained set of all entities of which the Entity is an attribute.
 String getName()
          Request the Entity's name.
 EntityValue getValue()
          Request the Entity's value.
protected  void removeBase(org.datamanager.kernel.Identifier base)
          Remove an Entity from the list of bases.
protected  void setAttributes(org.datamanager.kernel.Identifier[] attributeIdentifiers)
          Sets the list of all attributes on this Entity.
protected  void setBases(org.datamanager.kernel.Identifier[] baseIdentifiers)
          Sets the list of all bases on this Entity.
 void setValue(EntityValue newValue)
          Request a change of the Entity's value.
 void subscribe(EventHandler listener, EventConstraint constraint)
          Subscribe to the Entity for DataManagerEvents satisfying the given EventConstraint.
 String toString()
          A toString() method that overrides the one in Object.
 void unsubscribe(EventHandler handler)
          Remove all event subscriptions for which the EventHandler is subscribed.
 void writeBack()
          Writes any locally changed data back to the proxied Entity.
 
Methods inherited from class org.datamanager.kernel.Entity
chooseEntities, constraintAcceptsEntity, create, getEntities, makeIdentifierList
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CachingProxyEntity

protected CachingProxyEntity(Entity proxiedEntity)
Creates a new CachingProxyEntity proxying for the given Entity.

Method Detail

writeBack

public void writeBack()
               throws DataManagerException
Writes any locally changed data back to the proxied Entity.

DataManagerException

finalize

public void finalize()
              throws DataManagerException
Overrides:
finalize in class Object
DataManagerException

attach

public void attach(Entity attribute)
            throws DataManagerException
Description copied from class: Entity
Attach the given Entity as an attribute.

Specified by:
attach in class Entity
Parameters:
attribute - The Entity to attach.
Throws:
DataManagerException

detach

public void detach(Entity attribute)
            throws DataManagerException
Description copied from class: Entity
Detach the given Entity.

Specified by:
detach in class Entity
Parameters:
attribute - The Entity to detach.
Throws:
DataManagerException

attach

public void attach(org.datamanager.kernel.Identifier attribute)
            throws DataManagerException
Description copied from class: Entity
Attach the Entity with the given Identifier as an attribute.

Specified by:
attach in class Entity
Parameters:
attribute - The Identifier of the Entity to attach.
Throws:
DataManagerException

setAttributes

protected void setAttributes(org.datamanager.kernel.Identifier[] attributeIdentifiers)
                      throws DataManagerException
Description copied from class: Entity
Sets the list of all attributes on this Entity.

Specified by:
setAttributes in class Entity
DataManagerException

addBase

protected void addBase(org.datamanager.kernel.Identifier base)
                throws DataManagerException
Description copied from class: Entity
Add an Entity to the list of bases. This should only be called when the base is adding the EntityEntity as an attribute, that is, this should only be called by attach().

Specified by:
addBase in class Entity
Parameters:
base - The Identifier of the Entity that is a new base.
Throws:
DataManagerException

setBases

protected void setBases(org.datamanager.kernel.Identifier[] baseIdentifiers)
                 throws DataManagerException
Description copied from class: Entity
Sets the list of all bases on this Entity.

Specified by:
setBases in class Entity
DataManagerException

detach

public void detach(org.datamanager.kernel.Identifier attribute)
            throws DataManagerException
Description copied from class: Entity
Detach the Entity with the given Identifier.

Specified by:
detach in class Entity
Parameters:
attribute - The Identifier of the Entity to detach.
Throws:
DataManagerException

removeBase

protected void removeBase(org.datamanager.kernel.Identifier base)
                   throws DataManagerException
Description copied from class: Entity
Remove an Entity from the list of bases. This should only be called by the base as it removes the Entity as an attribute (which it does automatically), that is, this should only be called by detach().

Specified by:
removeBase in class Entity
Parameters:
base - The Identifier of the Entity that will no longer be a base.
Throws:
DataManagerException

getName

public String getName()
               throws DataManagerException
Description copied from class: Entity
Request the Entity's name.

Specified by:
getName in class Entity
Returns:
The Entity's name.
Throws:
DataManagerException

getValue

public EntityValue getValue()
                     throws DataManagerException
Description copied from class: Entity
Request the Entity's value.

Specified by:
getValue in class Entity
Returns:
The Entity's value.
Throws:
DataManagerException

setValue

public void setValue(EntityValue newValue)
              throws DataManagerException
Description copied from class: Entity
Request a change of the Entity's value.

Specified by:
setValue in class Entity
Parameters:
newValue - The new EntityValue that you wish to give the Entity.
Throws:
DataManagerException

getAttributes

public Entity[] getAttributes(EntityConstraint constraint)
                       throws DataManagerException
Description copied from class: Entity
Request a constrained set of all entities linked to the Entity.

Specified by:
getAttributes in class Entity
Parameters:
constraint - A constraint with which to filter attributes.
Returns:
An array of entities that are attributes of the Entity and satisfy the given constraint.
Throws:
DataManagerException

getBases

public Entity[] getBases(EntityConstraint constraint)
                  throws DataManagerException
Description copied from class: Entity
Request a constrained set of all entities of which the Entity is an attribute.

Specified by:
getBases in class Entity
Parameters:
constraint - The EntityConstraint that you wish to apply to get the bases of the Entity.
Returns:
An array of entities that are bases of the Entity and satisfy the given constraint.
Throws:
DataManagerException

subscribe

public void subscribe(EventHandler listener,
                      EventConstraint constraint)
               throws DataManagerException
Description copied from class: Entity
Subscribe to the Entity for DataManagerEvents satisfying the given EventConstraint.

Specified by:
subscribe in interface EventGenerator
Specified by:
subscribe in class Entity
Parameters:
listener - The EventHandler that will receive the events.
constraint - The constraint used to filter events.
Throws:
DataManagerException

unsubscribe

public void unsubscribe(EventHandler handler)
                 throws DataManagerException
Description copied from class: Entity
Remove all event subscriptions for which the EventHandler is subscribed.

Specified by:
unsubscribe in interface EventGenerator
Specified by:
unsubscribe in class Entity
Parameters:
handler - The EventHandler to unsubscribe.
Throws:
DataManagerException

toString

public String toString()
Description copied from class: Entity
A toString() method that overrides the one in Object.

Specified by:
toString in class Entity
Returns:
A String representation of this entity.


See the Helium Website