|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object i3.dragos.gm.core.proxy.GraphEntityProxy
public class GraphEntityProxy
A GraphEntityProxy
delegates all method calls to the
underlying graph entity 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 GraphEntity |
proxiedEntity
The graph entity we wrap. |
Constructor Summary | |
---|---|
GraphEntityProxy(GraphEntity proxiedEntity)
Constructs a new wrapper for a graph entity. |
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.Collection<? extends GraphEntity> |
getAdjacentGraphEntities(ConnectionMode connectionMode,
EdgeClass type,
boolean includeSubClasses)
Returns all adjacent graph entities connected through Edges. |
java.util.Collection<? extends Relation> |
getAdjacentRelations(ConnectionMode connectionMode,
RelationClass type,
boolean includeSubClasses)
Returns all adjacent Relations connected through RelationEnds. |
java.util.Collection<? extends Relation> |
getAdjacentRelations(ConnectionMode connectionMode,
RelationEndClass type,
boolean includeSubClasses)
Returns all adjacent Relations connected through RelationEnds. |
java.util.Map<java.lang.String,java.io.Serializable> |
getAllMetaAttributes()
Returns a map containing all currently set meta-attribute key-value pairs. |
java.util.Map<Attribute,java.io.Serializable> |
getAllValidAttributeValues()
Returns a map containg all attributes which have a valid value at the moment. |
java.io.Serializable |
getAttributeValue(Attribute attribute)
Returns the value of the attribute. |
DataSourceURL |
getDataSourceURL()
Returns the URL to the data source that stores this graph entity. |
java.util.Collection<? extends Edge> |
getEdges(ConnectionMode connectionMode)
Returns a collection containing the ( Edge ) of all edges
of the requested kind connected to this graph element. |
java.util.Collection<? extends Edge> |
getEdges(ConnectionMode connectionMode,
EdgeClass type,
boolean includeSubClasses)
Returns a collection containing the ( Edge ) of all edges
of the requested kind and type connected to this graph element. |
GraphEntityClass |
getGraphEntityClass()
Returns the graph entity's type. |
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. |
Graph |
getParent()
Returns the graph this graph element is contained in. |
GraphEntity |
getProxyGraphEntity()
Returns the graph entity which is encapsulated by this proxy. |
java.util.Collection<? extends RelationEnd> |
getRelationEnds(ConnectionMode connectionMode)
Returns a collection containing all relation ends of the requested kind connected to this graph element. |
java.util.Collection<? extends RelationEnd> |
getRelationEnds(ConnectionMode connectionMode,
RelationClass type,
boolean includeSubClasses)
Returns a collection containing all relation ends of the requested kind and type connected to this graph element. |
java.util.Collection<? extends RelationEnd> |
getRelationEnds(ConnectionMode connectionMode,
RelationEndClass type,
boolean includeSubClasses)
Returns a collection containing all relation ends of the requested kind and type connected to this graph element. |
GraphEntity |
getWrappedGraphEntity()
Returns the wrapped entity, 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 |
isAttributeValid(Attribute attribute)
Returns true if the attribute's value is valid and
false otherwise. |
boolean |
isIncident(Edge edge)
Returns true if the specified edge is connected to this
graph element and false otherwise. |
boolean |
isIncident(RelationEnd relationEnd)
Returns true if the specified relation end is connected
to this graph element and 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. |
void |
putAttributeValue(Attribute attribute,
java.io.Serializable value)
Stores a new value for the attribute and sets its validity to true . |
void |
setAttributeInvalid(Attribute attribute)
Marks an attribute's value as invalid. |
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 |
---|
protected final GraphEntity proxiedEntity
Constructor Detail |
---|
public GraphEntityProxy(GraphEntity proxiedEntity)
proxiedEntity
- The entity to be wrapped.Method Detail |
---|
public GraphEntity getProxyGraphEntity()
public DataSourceURL getDataSourceURL()
null
.
getDataSourceURL
in interface GraphEntity
public java.io.Serializable getInternalIdentifier()
To retrieve the entity use GraphPool.getGraphEntityByInternalIdentifier(Serializable)
.
As alternative you may consider to use the classes in the package
i3.dragos.gm.core.id
.
getInternalIdentifier
in interface GraphEntity
public GraphEntityClass getGraphEntityClass() throws DragosException
null
.
getGraphEntityClass
in interface GraphEntity
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 GraphEntity
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 GraphEntity
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 Graph getParent() throws DragosException
null
for and only for top-level graphs.
getParent
in interface GraphEntity
DragosException
public void putAttributeValue(Attribute attribute, java.io.Serializable value) throws EntityNotFoundException, DragosException, java.lang.IllegalArgumentException
true
.
putAttributeValue
in interface GraphEntity
attribute
- The attribute.value
- The new value of the attribute. May be null
.
EntityNotFoundException
- if the attribute is not defined
for this entity.
DragosException
- if something went wrong.
java.lang.IllegalArgumentException
- if id is null
or does not
match the attribute's value Java class type.public java.io.Serializable getAttributeValue(Attribute attribute) throws EntityNotFoundException, InvalidValueException, DragosException
null
.
The check whether the attribute is defined for this entity's class (which might result in an EntityNotFoundException) has to be performed every time, even when the non-existance of such an attribute in the implementations attribute map already would be sufficient to throw an InvalidValueException!
In other words: check the Attribute first, before trying to look up
the value.
This ensures conistency with the other attribute handling
methods and helps detect user errors.
getAttributeValue
in interface GraphEntity
attribute
- The attribute that should be retrieved.
EntityNotFoundException
- if the attribute is not defined
stored for this entity.
InvalidValueException
- if the value of the attribute is not valid
(explicitly marked invalid or not set yet).
DragosException
- if something went wrong.public java.util.Map<Attribute,java.io.Serializable> getAllValidAttributeValues() throws DragosException
Attribute
, Object}.
getAllValidAttributeValues
in interface GraphEntity
DragosException
- if something went wrong.public void setAttributeInvalid(Attribute attribute) throws EntityNotFoundException, DragosException
The check whether this Attribute is defined for this entity's class
(which might result in an EntityNotFoundException) has to be performed
every time, even when the non-existance of such an attribute in the
implementations attribute map already would be sufficient return
without above check, since the attribute obviously must be invalid
already!
This ensures conistency with the other attribute handling
methods and helps detect user errors.
setAttributeInvalid
in interface GraphEntity
attribute
- The attribute.
EntityNotFoundException
- if this attribute is not defined for this entity.
DragosException
- if something went wrong.public boolean isAttributeValid(Attribute attribute) throws EntityNotFoundException, DragosException
true
if the attribute's value is valid and
false
otherwise.
The check whether this Attribute is defined for this entity's class
(which might result in an EntityNotFoundException) has to be performed
every time, even when the non-existance of such an attribute in the
implementations attribute map already would be sufficient to return
false
without above check!
This ensures conistency with the other attribute handling
methods and helps detect user errors.
isAttributeValid
in interface GraphEntity
attribute
- The attribute.
true
if the attribute's value is valid and
false
otherwise.
EntityNotFoundException
- if this attribute is not defined for this entity.
DragosException
- if something went wrong.public java.util.Collection<? extends Edge> getEdges(ConnectionMode connectionMode) throws DragosException
Edge
) of all edges
of the requested kind connected to this graph element.
getEdges
in interface GraphEntity
connectionMode
- The kind of edges that should be returned.
Edge
) of all edges
of the requested kind connected to this graph element.
DragosException
- if something went wrong.public java.util.Collection<? extends Edge> getEdges(ConnectionMode connectionMode, EdgeClass type, boolean includeSubClasses) throws EntityNotFoundException, DragosException
Edge
) of all edges
of the requested kind and type connected to this graph element.
getEdges
in interface GraphEntity
connectionMode
- The kind of edges that should be returned.type
- The type of edges wanted (null
means "any
type").includeSubClasses
- If and only if true
, this method will
also match edges whose EdgeClass is a subclass of the specified
type (ignored if type == null
).
Edge
) of all edges
of the requested kind and type connected to this graph element.
EntityNotFoundException
- if the type for the edge couldn't be
found.
DragosException
- if something went wrong.public boolean isIncident(Edge edge) throws DragosException
true
if the specified edge is connected to this
graph element and false
otherwise.
isIncident
in interface GraphEntity
edge
- The edge, which will be checked.
true
if the specified edge is connected to this
graph element and false
otherwise.
DragosException
- if something went wrong.public java.util.Collection<? extends GraphEntity> getAdjacentGraphEntities(ConnectionMode connectionMode, EdgeClass type, boolean includeSubClasses) throws EntityNotFoundException, DragosException
getAdjacentGraphEntities
in interface GraphEntity
connectionMode
- The kind of edges that should be followed.type
- The type of edges to follow (null
means "any
type").includeSubClasses
- If and only if true
, this method will
also match edges whose EdgeClass is a subclass of the specified
type (ignored if type == null
).
EntityNotFoundException
- if the type for the edge couldn't be found.
DanglingReferenceException
- if this method would have to traverse a dangling edge.
DragosException
- if something went wrong.public java.util.Collection<? extends RelationEnd> getRelationEnds(ConnectionMode connectionMode) throws DragosException
"Connected" means that this graph entity is
the "relatedElement" of the relation end. This implies that,
if this method is called on a relation, relation ends belonging to
the relation will only be returned if they point back to it.
To access all dependent relation ends of a relation, see
Relation.getAllRelationEndsOfRelation()
.
getRelationEnds
in interface GraphEntity
connectionMode
- The kind of relation ends that should be returned.
DragosException
- if something went wrong.public java.util.Collection<? extends RelationEnd> getRelationEnds(ConnectionMode connectionMode, RelationClass type, boolean includeSubClasses) throws EntityNotFoundException, DragosException
"Connected" means that this graph entity is
the "relatedElement" of the relation end. This implies that,
if this method is called on a relation, relation ends belonging to
the relation will only be returned if they point back to it.
To access all dependent relation ends of a relation, see
Relation.getAllRelationEndsOfRelation()
.
getRelationEnds
in interface GraphEntity
connectionMode
- The kind of relation ends that should be returned.type
- The type of the relation the relation end belongs to
(null
means "any type").includeSubClasses
- If and only if true
, this method
will also match relations whose RelationClass is a subclass
of the specified type (ignored if type == null
).
EntityNotFoundException
- if the type for the relation couldn't be
found.
DragosException
- if something went wrong.public java.util.Collection<? extends RelationEnd> getRelationEnds(ConnectionMode connectionMode, RelationEndClass type, boolean includeSubClasses) throws EntityNotFoundException, DragosException
"Connected" means that this graph entity is
the "relatedElement" of the relation end. This implies that,
if this method is called on a relation, relation ends belonging to
the relation will only be returned if they point back to it.
To access all dependent relation ends of a relation, see
Relation.getAllRelationEndsOfRelation()
.
getRelationEnds
in interface GraphEntity
connectionMode
- The kind of relation ends that should be returned.type
- The type the relation ends have to belong to
(null
means "any type").includeSubClasses
- If and only if true
, this method
will also match relation ends whose RelationEndClass is a subclass
of the specified type (ignored if type == null
).
EntityNotFoundException
- if the type for the relation ends couldn't be
found.
DragosException
- if something went wrong.public boolean isIncident(RelationEnd relationEnd) throws DragosException
true
if the specified relation end is connected
to this graph element and false
otherwise.
isIncident
in interface GraphEntity
relationEnd
- The relationEnd, which will be checked.
true
if the specified relationEnd is connected to this
graph element and false
otherwise.
DragosException
- if something went wrong.public java.util.Collection<? extends Relation> getAdjacentRelations(ConnectionMode connectionMode, RelationClass type, boolean includeSubClasses) throws EntityNotFoundException, DragosException
As with GraphEntity.getRelationEnds(ConnectionMode)
,
"connected" means that this graph entity is the
"relatedElement" of the relation end.
This implies that, if this method is called on a relation,
relation ends belonging to the relation will only be returned
if they point back to it.
For accessing the dependent relation ends of a relation, or the
entities connected through those, there are a number of
methods in Relation
.
getAdjacentRelations
in interface GraphEntity
connectionMode
- The kind of relation ends that should be followed.type
- The type of Relations whose RelationEnds we should follow (null
means "any
type").includeSubClasses
- If and only if true
, this method will
also follow relation ends belonging to instances of subclasses
of the specified RelationClass (ignored if type == null
).
EntityNotFoundException
- if the type for the Relation couldn't be found.
DragosException
- if something went wrong.public java.util.Collection<? extends Relation> getAdjacentRelations(ConnectionMode connectionMode, RelationEndClass type, boolean includeSubClasses) throws EntityNotFoundException, DragosException
As with GraphEntity.getRelationEnds(ConnectionMode)
,
"connected" means that this graph entity is the
"relatedElement" of the relation end.
This implies that, if this method is called on a relation,
relation ends belonging to the relation will only be returned
if they point back to it.
For accessing the dependent relation ends of a relation, or the
entities connected through those, there are a number of
methods in Relation
.
getAdjacentRelations
in interface GraphEntity
connectionMode
- The kind of relation ends that should be followed.type
- The type of RelationEnds we should follow (null
means "any
type").includeSubClasses
- If and only if true
, this method will
also follow relation ends whose RelationEndClass is a subclass of the specified
type (ignored if type == null
).
EntityNotFoundException
- if the type for the RelationEnd couldn't be found.
DragosException
- if something went wrong.public GraphEntity getWrappedGraphEntity()
null
if none.
For subinterfaces defined in the core GM (like Edge, Node...),
the returned value is guaranteed to be an instance of the same
subinterface.
getWrappedGraphEntity
in interface GraphEntity
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 |