|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object i3.dragos.gm.core.proxy.GraphEntityClassProxy
public class GraphEntityClassProxy
A GraphEntityClassProxy
delegates all method calls to the
underlying graph entity class except for those that access fields which are
used after a graph entity has been deleted. The fields are:
For details on background see:
ProxyWrapper
.
Field Summary | |
---|---|
protected GraphEntityClass |
proxiedEntityClass
The graph entity class we wrap. |
Constructor Summary | |
---|---|
GraphEntityClassProxy(GraphEntityClass proxiedEntityClass)
Constructs a new wrapper for a graph entity class. |
Method Summary | |
---|---|
void |
addSubClass(GraphEntityClass clazz)
Adds the specified class to the set of sub classes of this class. |
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. |
Attribute |
declareAttribute(java.lang.String attrName,
java.lang.Class type)
Declares a new attribute with the given name and type. |
boolean |
equals(java.lang.Object o)
Checks for equality with another object. |
java.util.Collection<? extends Attribute> |
getAllDeclaredAttributes()
Returns a collection containg all attributes declared in this graph element class and all its super classes. |
java.util.Map<java.lang.String,java.io.Serializable> |
getAllMetaAttributes()
Returns a map containing all currently set meta-attribute key-value pairs. |
java.util.Collection<? extends GraphEntityClass> |
getAllSubClasses()
Returns all sub classes of this class. |
java.util.Collection<? extends GraphEntityClass> |
getAllSuperClasses()
Returns all super classes of this class. |
Attribute |
getAttribute(java.lang.String attrName)
Returns the attribute with the given name. |
DataSourceURL |
getDataSourceURL()
Returns the URL to the data source that stores this graph entity class. |
java.util.Collection<? extends Attribute> |
getDeclaredAttributes()
Returns a collection containing the attributes declared for the schema entity. |
java.util.Collection<? extends GraphEntityClass> |
getDirectSubClasses()
Returns all direct sub classes of this class. |
java.util.Collection<? extends GraphEntityClass> |
getDirectSuperClasses()
Returns all direct super classes of this class. |
java.io.Serializable |
getInternalIdentifier()
Returns the internal identifier used to uniquely identify this object in the storage backend. |
java.io.Serializable |
getMetaAttribute(java.lang.String key)
Returns the current value of a meta-attribute. |
java.lang.String |
getName()
Returns the name of the graph entity class. |
GraphEntityClass |
getProxyGraphEntityClass()
Returns the graph entity class which is encapsulated by this proxy. |
GraphEntityClass |
getWrappedGraphEntityClass()
Returns the wrapped entity class, null if none. |
boolean |
hasAttribute(java.lang.String attrName)
Returns true if an attribute with the given name is
declared in the graph entity class. |
int |
hashCode()
To comply with the general contract for Object.hashCode() , it is
recommended to return the hash code of the internal identifier. |
boolean |
isAbstract()
Returns true if the schema entity is abstract or
false otherwise. |
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. |
boolean |
isSubClassOf(GraphEntityClass clazz)
Returns true if the specified class is the same as this
class or a super class of this class and false otherwise. |
boolean |
isSuperClassOf(GraphEntityClass clazz)
Returns true if the specified class is the same as this
class or a sub class of this class and false otherwise. |
void |
removeSubClass(GraphEntityClass clazz)
Removes the specified class from the set of direct sub classes of this class. |
void |
setMetaAttribute(java.lang.String key,
java.io.Serializable value)
Sets a meta-attribute. |
java.lang.String |
toString()
|
void |
undeclareAllAttributes()
Undeclares all attributes of this graph entity class. |
void |
undeclareAttribute(Attribute attribute)
Undeclares an attribute. |
void |
undeclareAttribute(java.lang.String attrName)
Undeclares the attribute with the given name. |
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 |
---|
protected final GraphEntityClass proxiedEntityClass
Constructor Detail |
---|
public GraphEntityClassProxy(GraphEntityClass proxiedEntityClass)
proxiedEntityClass
- The entity class to be wrapped.Method Detail |
---|
public GraphEntityClass getProxyGraphEntityClass()
public DataSourceURL getDataSourceURL()
null
.
getDataSourceURL
in interface GraphEntityClass
public java.io.Serializable getInternalIdentifier()
To retrieve the entity use
Schema.getGraphEntityClassByInternalIdentifier(Serializable)
As
alternative you may consider to use the classes in the package
i3.dragos.gm.core.schema.id
.
getInternalIdentifier
in interface GraphEntityClass
public java.lang.String getName() throws DragosException
getName
in interface GraphEntityClass
DragosException
- if something went wrong.public boolean equals(java.lang.Object o)
This object is considered equal if all of the following conditions are met:
o != null
o instanceof GraphEntity
getDataSourceURL().equals(((GraphEntity) o).getDataSourceURL())
getInternalIdentifier().equals(((GraphEntity) o).getInternalIdentifier())
Subclasses and implementations might want to extend this list by adding
assertions comparing additional or internal data (e.g. the type of the
graph entity). However, equality must only be determined by the above
rules, preferably by using super.equals(o)
, and any
difference in the additional data for two object equal according to the
rules above is to be considered an error.
equals
in interface GraphEntityClass
equals
in class java.lang.Object
o
- The Object to compare to.
true
if o
is equal according to
above rules, false
otherwise.public int hashCode()
Object.hashCode()
, it is
recommended to return the hash code of the internal identifier.
hashCode
in interface GraphEntityClass
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public void checkExistence() throws java.lang.RuntimeException
checkExistence
in interface ExistenceCheckable
java.lang.RuntimeException
- if this object no longer exists or an error occurred while accessing the GraphPool.public void checkExistenceOptional() throws java.lang.RuntimeException
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); }
checkExistenceOptional
in interface ExistenceCheckable
java.lang.RuntimeException
- if this object no longer exists or an error occurred while accessing the GraphPool.public Attribute declareAttribute(java.lang.String attrName, java.lang.Class type) throws EntityAlreadyExistsException, DragosException
null
.
declareAttribute
in interface GraphEntityClass
attrName
- The name of the attribute.type
- The type of the attribute.
EntityAlreadyExistsException
- if an attribute with the given name already exists.
DragosException
- if something went wrong.public void undeclareAttribute(java.lang.String attrName) throws EntityNotFoundException, DragosException
All instances of this attribute are removed from the graph pool
associated with this schema, using
GraphPool.removeAllAttributeInstances(Attribute)
,
before the attribute itself is undeclared.
Note that this method only works for attributes declared for this class, not for those declared for any super classes in the inheritance hierachy.
undeclareAttribute
in interface GraphEntityClass
attrName
- The name of the attribute.
EntityNotFoundException
- if no attribute with the given name is declared for this
GraphEntityClass.
DragosException
- if something went wrong.public void undeclareAttribute(Attribute attribute) throws EntityNotFoundException, DragosException
All instances of this attribute are removed from the graph pool
associated with this schema, using
GraphPool.removeAllAttributeInstances(Attribute)
,
before the attribute itself is undeclared.
Note that this method only works for attributes declared for this class, not for those declared for any super classes in the inheritance hierachy.
undeclareAttribute
in interface GraphEntityClass
attribute
- The attribute.
EntityNotFoundException
- if the attribute is not declared for this GraphEntityClass.
DragosException
- if something went wrong.public void undeclareAllAttributes() throws DragosException
All instances of an attribute are removed from the graph pool associated
with this schema, using
GraphPool.removeAllAttributeInstances(Attribute)
,
before the attribute itself is undeclared. You may first remove all
instances of all attributes, and then undeclare all attributes at once,
or you may process each attribute seperately at your discretion.
Note that this method only works for attributes declared for this class, not for those declared for any super classes in the inheritance hierachy.
undeclareAllAttributes
in interface GraphEntityClass
DragosException
- if something went wrong.public java.util.Collection<? extends Attribute> getDeclaredAttributes() throws DragosException
Attribute
.
Note that this method only works for attributes declared for this class, not for those declared for any super classes in the inheritance hierachy.
getDeclaredAttributes
in interface GraphEntityClass
DragosException
- if something went wrong.public Attribute getAttribute(java.lang.String attrName) throws EntityNotFoundException, DragosException
Note that this method only works for attributes declared for this class, not for those declared for any super classes in the inheritance hierachy.
getAttribute
in interface GraphEntityClass
attrName
- The name of the requested attribute.
EntityNotFoundException
- if no attribute with the given name exists.
DragosException
- if something went wrong.public boolean hasAttribute(java.lang.String attrName) throws DragosException
true
if an attribute with the given name is
declared in the graph entity class.
Note that this method only works for attributes declared for this class, not for those declared for any super classes in the inheritance hierachy.
hasAttribute
in interface GraphEntityClass
attrName
- The name of the requested attribute.
DragosException
- if something went wrong.public void addSubClass(GraphEntityClass clazz) throws EntityNotFoundException, DragosException
If clazz
is already a direct sub class of this
class, no action will be performed. Of course, this class will be added
to the list of super classes of clazz
.
If adding this sub class would result in circular references, a InheritanceCycleException is thrown, and no action will be performed.
When called on a specialized subinterface of GraphEntityClass (e.g. EdgeClass), the argument must be of the same type. You can not subclass an EdgeClass with a RelationClass, for example. If the parameter is invalid, a DragosException is thrown, and no action will be performed.
addSubClass
in interface GraphEntityClass
clazz
- The class which should be a sub class of this class.
EntityNotFoundException
- if clazz does not exist in this schema.
InheritanceCycleException
- if the inheritance relation would introduce a cycle.
DragosException
- if clazz is of a different specialized type, or an internal error occurs.public void removeSubClass(GraphEntityClass clazz) throws EntityNotFoundException, DragosException
clazz
.
removeSubClass
in interface GraphEntityClass
clazz
- The sub class to remove.
EntityNotFoundException
- if clazz does not exist in this schema or is not a direct sub
class.
DragosException
- in case of internal errors.public java.util.Collection<? extends GraphEntityClass> getDirectSuperClasses() throws DragosException
GraphEntityClass
.
getDirectSuperClasses
in interface GraphEntityClass
DragosException
- if something went wrong.public java.util.Collection<? extends GraphEntityClass> getAllSuperClasses() throws DragosException
GraphEntityClass
.
While the sub class relationship is reflective (meaning
c.isSuperClassOf(c)
returns true
for any
GraphEntityClass c
), the class this method is called on
itself will not be included in the returned Collection. This decision was
made because in practical use of this method one in most cases is only
interested in real super classes.
getAllSuperClasses
in interface GraphEntityClass
DragosException
- if something went wrong.public java.util.Collection<? extends GraphEntityClass> getDirectSubClasses() throws DragosException
GraphEntityClass
.
getDirectSubClasses
in interface GraphEntityClass
DragosException
- if something went wrong.public java.util.Collection<? extends GraphEntityClass> getAllSubClasses() throws DragosException
GraphEntityClass
.
While the sub class relationship is reflective (meaning
c.isSubClassOf(c)
returns true
for any
GraphEntityClass c
), the class this method is called on
itself will not be included in the returned Collection. This decision was
made because in practical use of this method one in most cases is only
interested in real sub classes.
getAllSubClasses
in interface GraphEntityClass
DragosException
- if something went wrong.public boolean isSuperClassOf(GraphEntityClass clazz) throws EntityNotFoundException, DragosException
true
if the specified class is the same as this
class or a sub class of this class and false
otherwise.
isSuperClassOf
in interface GraphEntityClass
clazz
- The class which is tested.
true
if the specified class is a super class of
this class and false
otherwise.
EntityNotFoundException
- if the graph element class could not be found.
DragosException
- if something went wrong.public boolean isSubClassOf(GraphEntityClass clazz) throws EntityNotFoundException, DragosException
true
if the specified class is the same as this
class or a super class of this class and false
otherwise.
isSubClassOf
in interface GraphEntityClass
clazz
- The class which is tested.
true
if the specified class is a super class of
this class and false
otherwise.
EntityNotFoundException
- if the graph element class could not be found.
DragosException
- if something went wrong.public boolean isAbstract() throws DragosException
true
if the schema entity is abstract or
false
otherwise. If a graph element class is abstract no
graph element can be constructed for it.
isAbstract
in interface GraphEntityClass
true
if the schema entity is abstract or
false
otherwise.
DragosException
- if something went wrong.public java.util.Collection<? extends Attribute> getAllDeclaredAttributes() throws DragosException
Attribute
.
getAllDeclaredAttributes
in interface GraphEntityClass
DragosException
- if something went wrong.public GraphEntityClass getWrappedGraphEntityClass()
null
if none.
For subinterfaces defined in the core GM (like EdgeClass, NodeClass...),
the returned value is guaranteed to be an instance of the same
subinterface.
getWrappedGraphEntityClass
in interface GraphEntityClass
null
if none.public void setMetaAttribute(java.lang.String key, java.io.Serializable value) throws EntityInUseException, DragosException
setMetaAttribute
in interface MetaAttributable
key
- The key that identifies the meta attribute.value
- The (new) value of this meta-attribute.
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.public void unsetMetaAttribute(java.lang.String key) throws EntityInUseException, DragosException
unsetMetaAttribute
in interface MetaAttributable
key
- The key that identifies the meta attribute.
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.public java.io.Serializable getMetaAttribute(java.lang.String key) throws EntityNotFoundException, DragosException
getMetaAttribute
in interface MetaAttributable
key
- The key that identifies the meta attribute.
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.public boolean isMetaAttributeSet(java.lang.String key) throws EntityNotFoundException, DragosException
isMetaAttributeSet
in interface MetaAttributable
key
- The key that identifies the meta attribute.
true
if the meta-attribute is set, false
otherwise.
DragosException
- if this object is no longer in its GraphPool/Schema, or something else went wrong.
EntityNotFoundException
public java.util.Map<java.lang.String,java.io.Serializable> getAllMetaAttributes() throws DragosException
getAllMetaAttributes
in interface MetaAttributable
Map
containing key-value pairs for all set meta-attributes.
DragosException
- if this object is no longer in its GraphPool/Schema, or something else went wrong.public boolean isMetaAttributeKeyReserved(java.lang.String key) throws DragosException
isMetaAttributeKeyReserved
in interface MetaAttributable
key
- The key in question.
true
if this meta-attribute key is reserved, false
otherwise.
DragosException
- if this object is no longer in its GraphPool/Schema, or something else went wrong.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |