public class HGRelType extends HGAtomTypeBase implements HGLink
Represents the type a "semantic" relationship. It carries the
name of the relationships and the types of its arguments. The latter
are simply the target set of a HGRelType
instance.
graph
Constructor and Description |
---|
HGRelType() |
HGRelType(HGHandle... targetTypes) |
HGRelType(String name) |
HGRelType(String name,
HGHandle... targetTypes) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
int |
getArity()
Return the number of targets of this link.
|
String |
getName() |
HGHandle |
getTargetAt(int i)
Return the ith target.
|
int |
hashCode() |
Object |
make(HGPersistentHandle handle,
LazyRef<HGHandle[]> targetSet,
IncidenceSetRef incidenceSet)
Construct a new run-time instance of a hypergraph atom.
|
void |
notifyTargetHandleUpdate(int i,
HGHandle handle)
Notify the
HGLink that one of its target atoms should be referred to
by a different HGHandle instance. |
void |
notifyTargetRemoved(int i)
Notify the
HGLink that one of its targets must be removed. |
void |
release(HGPersistentHandle handle)
Release a hypergraph value instance from the persistent store.
|
void |
setName(String name) |
HGPersistentHandle |
store(Object instance)
Store a run-time instance of a hypergraph atom into the hypergraph
HGStore
as a new atom. |
getHyperGraph, setHyperGraph, subsumes
public HGRelType()
public HGRelType(String name)
public HGRelType(HGHandle... targetTypes)
public Object make(HGPersistentHandle handle, LazyRef<HGHandle[]> targetSet, IncidenceSetRef incidenceSet)
HGAtomType
Construct a new run-time instance of a hypergraph atom. A plain node must
be constructed whenever the targetSet
parameter is null or of
length 0. Otherwise, a HGLink
instance must be constructed.
It is not required that all atom types be able to construct both plain (node)
atoms and HGLink
s. It is up to an HGAtomType
implementation
to support either or both. When a HGLink
counterpart is not available
for a particular run-time type, an implementation may choose to create an instance
of the default link value holder implementation HGValuedLink
, provided
by HyperGraph.
make
in interface HGAtomType
handle
- The HGPersistentHandle
of the atom value.targetSet
- When the atom is a link, this parameter holds the target set of
the link. When the atom is a node, the parameter is an array of 0 length.incidenceSet
- A lazy reference to the set of links pointing to this atom. This is
null
if we are constructing an internal/nested value of some complex type.null
.
In case the handle
points to an invalid instance (inexisting or with
a erronous layout), the method should throw a HGException
.public void release(HGPersistentHandle handle)
HGAtomType
Release a hypergraph value instance from the persistent store.
This method should be called when a HGPersistentHandle
returned from the store
is no longer in use.
release
in interface HGAtomType
handle
- The persistent handle of the value to release.public HGPersistentHandle store(Object instance)
HGAtomType
Store a run-time instance of a hypergraph atom into the hypergraph HGStore
as a new atom.
store
in interface HGAtomType
instance
- The atom instance.public String getName()
public void setName(String name)
public int getArity()
HGLink
Return the number of targets of this link. This number may be >= 0.
public HGHandle getTargetAt(int i)
HGLink
Return the ith target.
getTargetAt
in interface HGLink
i
- The index of the desired target. The range of this parameters must be
[0...getArity() - 1]
.public void notifyTargetHandleUpdate(int i, HGHandle handle)
HGLink
Notify the HGLink
that one of its target atoms should be referred to
by a different HGHandle
instance. Generally, implementation should update their reference
to this target with the passed in live handle.
IMPORTANT NOTE: This method should never be called by application
code. It is strictly reserved to the HyperGraph implementation which guarantees that
the new handle will always refer to the same atom. The method should essentially
perform a setTargetAt
operation, but a more elaborate name was chosen
to reflect the intended usage. Note also that the intent is not for an implementation
to attempt a database update! The intent is to only update the runtime representation
of the set of targets pointed to be this link.
notifyTargetHandleUpdate
in interface HGLink
i
- The index of the target that was loaded.handle
- The new live handle of the target atom.public void notifyTargetRemoved(int i)
HGLink
Notify the HGLink
that one of its targets must be removed. This
method is invoked by the system when the target at position i
refers
to an atom that is being deleted from the database. Implementation are required
to remove the target at that position from their implementation data structure.
It remains the system's responsibility to reflect that change in permanent
data storage.
An implementation may throw an IllegalArgumentException
if the target
cannot be removed from the link because it would somehow break the semantics of the
application or lead to an otherwise inconsistent state. Throwing such an exception would
indicate a fatal error and a very likely bug in the application.
notifyTargetRemoved
in interface HGLink
i
- The 0-based position of the target to be removed from this link.Copyright © 2015. All rights reserved.