i3.dragos.gm.core.schema
Class AbstractAttribute

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

public abstract class AbstractAttribute
extends java.lang.Object
implements Attribute

An AbstractAttribute uniquely identifies an attribute.

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

Constructor Summary
protected AbstractAttribute(DataSourceURL dataSourceURL, GraphEntityClass gec, java.io.Serializable identifier, java.lang.String name, java.lang.Class type)
          Constructs a new attribute.
 
Method Summary
abstract  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.
 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.lang.String getName()
          Returns the attribute's name.
 java.lang.Class getType()
          Returns the attribute's value type.
abstract  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)
          This default implementation always returns false.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface i3.dragos.gm.core.schema.Attribute
getWrappedAttribute
 
Methods inherited from interface i3.dragos.gm.core.schema.MetaAttributable
getAllMetaAttributes, getMetaAttribute, isMetaAttributeSet, setMetaAttribute, unsetMetaAttribute
 

Constructor Detail

AbstractAttribute

protected AbstractAttribute(DataSourceURL dataSourceURL,
                            GraphEntityClass gec,
                            java.io.Serializable identifier,
                            java.lang.String name,
                            java.lang.Class type)
                     throws java.lang.IllegalArgumentException
Constructs a new attribute.

Parameters:
dataSourceURL - The DataSourceURL of the schema this AbstractAttribute belongs to.
gec - The schema entity this attribute belongs to.
identifier - The identifier
name - The attribute's name.
type - The type of the attribute's value.
Throws:
java.lang.IllegalArgumentException - if gec, id, type is null or if name is null or is equal to an empty string.
Method Detail

getGraphEntityClass

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

Specified by:
getGraphEntityClass in interface Attribute
Returns:
the schema entity the attribute belongs to.

getInternalIdentifier

public final 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.

getName

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

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

getType

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

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

getDataSourceURL

public final 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.

hashCode

public abstract 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.

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.

isMetaAttributeKeyReserved

public boolean isMetaAttributeKeyReserved(java.lang.String key)
                                   throws DragosException
This default implementation always returns false.

Specified by:
isMetaAttributeKeyReserved in interface MetaAttributable
Parameters:
key - The key in question.
Returns:
false.
Throws:
DragosException - if something goes wrong.
See Also:
MetaAttributable

checkExistence

public abstract 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.


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