i3.dragos.gm.core.proxy
Class AttributeProxy

java.lang.Object
  extended by i3.dragos.gm.core.proxy.AttributeProxy
All Implemented Interfaces:
Attribute, ExistenceCheckable, MetaAttributable

public class AttributeProxy
extends java.lang.Object
implements Attribute

A AttributeProxy delegates all method calls to the underlying attribtue except for those that access fields which are used after a attribute has been deleted.

Author:
Boris Boehlen <boehlen@cs.rwth-aachen.de>

Field Summary
protected  Attribute proxiedAttribute
          The attribute we wrap.
 
Constructor Summary
AttributeProxy(Attribute proxiedAttribute)
          Constructs a new wrapper for an attribute.
 
Method Summary
 void checkExistence()
          Checks whether this object still exists, throwing an exception if not.
 void checkExistenceOptional()
          Checks whether this object still exists, throwing an exception if not.
 boolean equals(java.lang.Object o)
          Checks for equality with another object.
 java.util.Map<java.lang.String,java.io.Serializable> getAllMetaAttributes()
          Returns a map containing all currently set meta-attribute key-value pairs.
 DataSourceURL getDataSourceURL()
          Returns the DataSourceURL of the schema this attribute belongs to.
 GraphEntityClass getGraphEntityClass()
          Returns the schema entity the attribute belongs to.
 java.io.Serializable getInternalIdentifier()
          Returns the internal internal identifier of the attribute.
 java.io.Serializable getMetaAttribute(java.lang.String key)
          Returns the current value of a meta-attribute.
 java.lang.String getName()
          Returns the attribute's name.
 Attribute getProxyAttribute()
          Returns the attribute which is encapsulated by this proxy.
 java.lang.Class getType()
          Returns the attribute's value type.
 Attribute getWrappedAttribute()
          Returns the wrapped attribute, null if none.
 int hashCode()
          To comply with the general contract for Object.hashCode(), it is recommended to return the hash code of the internal identifier.
 boolean isMetaAttributeKeyReserved(java.lang.String key)
          Checks whether a meta-attribute key is reserved for internal use.
 boolean isMetaAttributeSet(java.lang.String key)
          Checks whether a meta-attribute is set.
 void setMetaAttribute(java.lang.String key, java.io.Serializable value)
          Sets a meta-attribute.
 java.lang.String toString()
          
 void unsetMetaAttribute(java.lang.String key)
          Removes a meta-attribute.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

proxiedAttribute

protected final Attribute proxiedAttribute
The attribute we wrap.

Constructor Detail

AttributeProxy

public AttributeProxy(Attribute proxiedAttribute)
Constructs a new wrapper for an attribute.

Parameters:
proxiedAttribute - The attribute to wrap.
Method Detail

getProxyAttribute

public Attribute getProxyAttribute()
Returns the attribute which is encapsulated by this proxy.

Returns:
attribute which is encapsulated by this proxy.

getDataSourceURL

public DataSourceURL getDataSourceURL()
Returns the DataSourceURL of the schema this attribute belongs to. The returned value is guaranteed to not be null.

Specified by:
getDataSourceURL in interface Attribute
Returns:
The DataSourceURL of the Schema this attribute belongs to.

getGraphEntityClass

public GraphEntityClass getGraphEntityClass()
                                     throws DragosException
Returns the schema entity the attribute belongs to.

Specified by:
getGraphEntityClass in interface Attribute
Returns:
the schema entity the attribute belongs to.
Throws:
DragosException - if something went wrong.

getInternalIdentifier

public java.io.Serializable getInternalIdentifier()
Returns the internal internal identifier of the attribute.

Specified by:
getInternalIdentifier in interface Attribute
Returns:
the internal internal identifier of the attribute.

hashCode

public int hashCode()
To comply with the general contract for Object.hashCode(), it is recommended to return the hash code of the internal identifier.

Specified by:
hashCode in interface Attribute
Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Checks for equality with another object.

This object is considered equal if all of the following conditions are met:

Subclasses and implementations might want to extend it by adding assertions comparing additional or internal data. However, equality must only be determined by above rules, preferably by using super.equals(o), and any differences in the additional data for two equal attributes is to be considered an error.

Specified by:
equals in interface Attribute
Overrides:
equals in class java.lang.Object
Parameters:
o - The Object to compare to.
Returns:
true if o is equal according to above rules, false otherwise.

getName

public java.lang.String getName()
Returns the attribute's name.

Specified by:
getName in interface Attribute
Returns:
the attribute's name.

getType

public java.lang.Class getType()
Returns the attribute's value type.

Specified by:
getType in interface Attribute
Returns:
the attribute's value type.

getWrappedAttribute

public Attribute getWrappedAttribute()
Returns the wrapped attribute, null if none.

Specified by:
getWrappedAttribute in interface Attribute
Returns:
the wrapped attribute, null if none.

checkExistence

public void checkExistence()
                    throws java.lang.RuntimeException
Checks whether this object still exists, throwing an exception if not. This method should be called by all writing operations.

Specified by:
checkExistence in interface ExistenceCheckable
Throws:
java.lang.RuntimeException - if this object no longer exists or an error occurred while accessing the GraphPool.

checkExistenceOptional

public void checkExistenceOptional()
                            throws java.lang.RuntimeException
Checks whether this object still exists, throwing an exception if not. This method should be called by all reading operations.

A useful default implementation would be as follows:

 try {
     GraphPool gp = GraphPoolFactory.get(getDataSourceURL());
     if (gp.getForceExistenceCheckOnRead()) {
         checkExistence();
     }
 } catch (DragosException e) {
     String message = "Caught GraphPoolException while trying to determine whether to perform checks on read operation!";
     log.error(message);
     throw new RuntimeException(message);
 }
 

Specified by:
checkExistenceOptional in interface ExistenceCheckable
Throws:
java.lang.RuntimeException - if this object no longer exists or an error occurred while accessing the GraphPool.

getAllMetaAttributes

public java.util.Map<java.lang.String,java.io.Serializable> getAllMetaAttributes()
                                                                          throws DragosException
Returns a map containing all currently set meta-attribute key-value pairs.

Specified by:
getAllMetaAttributes in interface MetaAttributable
Returns:
A Map containing key-value pairs for all set meta-attributes.
Throws:
DragosException - if this object is no longer in its GraphPool/Schema, or something else went wrong.

getMetaAttribute

public java.io.Serializable getMetaAttribute(java.lang.String key)
                                      throws EntityNotFoundException,
                                             DragosException
Returns the current value of a meta-attribute.

Specified by:
getMetaAttribute in interface MetaAttributable
Parameters:
key - The key that identifies the meta attribute.
Returns:
The current value of this meta-attribute.
Throws:
EntityNotFoundException - if no meta-attribute with that name exists.
DragosException - if this object is no longer in its GraphPool/Schema, or something else went wrong.

isMetaAttributeKeyReserved

public boolean isMetaAttributeKeyReserved(java.lang.String key)
                                   throws DragosException
Checks whether a meta-attribute key is reserved for internal use.

Specified by:
isMetaAttributeKeyReserved in interface MetaAttributable
Parameters:
key - The key in question.
Returns:
true if this meta-attribute key is reserved, false otherwise.
Throws:
DragosException - if this object is no longer in its GraphPool/Schema, or something else went wrong.

isMetaAttributeSet

public boolean isMetaAttributeSet(java.lang.String key)
                           throws EntityNotFoundException,
                                  DragosException
Checks whether a meta-attribute is set. Meta-attributes with reserved keys are not treated in any special way by this method.

Specified by:
isMetaAttributeSet in interface MetaAttributable
Parameters:
key - The key that identifies the meta attribute.
Returns:
true if the meta-attribute is set, false otherwise.
Throws:
DragosException - if this object is no longer in its GraphPool/Schema, or something else went wrong.
EntityNotFoundException

setMetaAttribute

public void setMetaAttribute(java.lang.String key,
                             java.io.Serializable value)
                      throws EntityInUseException,
                             DragosException
Sets a meta-attribute. Any old value will be overwritten.

Specified by:
setMetaAttribute in interface MetaAttributable
Parameters:
key - The key that identifies the meta attribute.
value - The (new) value of this meta-attribute.
Throws:
EntityInUseException - if a key name is reserved for internal use.
DragosException - if this object is no longer in its GraphPool/Schema, or something else went wrong.

unsetMetaAttribute

public void unsetMetaAttribute(java.lang.String key)
                        throws EntityInUseException,
                               DragosException
Removes a meta-attribute. If no value was set before, this method has no effect.

Specified by:
unsetMetaAttribute in interface MetaAttributable
Parameters:
key - The key that identifies the meta attribute.
Throws:
EntityInUseException - if a key name is reserved for internal use.
DragosException - if this object is no longer in its GraphPool/Schema, or something else went wrong.


Copyright © 2002-2008 RWTH Aachen, Department of Computer Science 3 (Software Engineering). All Rights Reserved.