public class HGPlainLink extends Object implements HGLink, Iterable<HGHandle>
A default HGLink
implementation provided by hypergraph.
Modifier and Type | Field and Description |
---|---|
protected HGHandle[] |
outgoingSet
An array of
HGHandle s representing the target set
of this link. |
Modifier | Constructor and Description |
---|---|
protected |
HGPlainLink()
A default constructor is needed when using Java serialization, but it should
never be called by the outside world.
|
|
HGPlainLink(HGHandle... outgoingSet)
Construct a new link with the specified outgoing set.
|
Modifier and Type | Method and Description |
---|---|
int |
getArity()
Return the number of elements in the target set of this link.
|
HGHandle |
getTargetAt(int i)
Return the
i th target of this link. |
Iterator<HGHandle> |
iterator() |
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. |
String |
toString() |
protected String |
toStringHdlArr(HGHandle[] hdls) |
protected HGHandle[] outgoingSet
HGHandle
s representing the target set
of this link. The array should never be null
. An
empty target set should be represented by an 0 length array.protected HGPlainLink()
A default constructor is needed when using Java serialization, but it should never be called by the outside world.
public HGPlainLink(HGHandle... outgoingSet)
Construct a new link with the specified outgoing set.
outgoingSet
- A non-null array of valid HGHandle
s of length > 0.public int getArity()
Return the number of elements in the target set of this link.
public HGHandle getTargetAt(int i)
Return the i
th target of this link.
getTargetAt
in interface HGLink
i
- The index of the desired target. The range of this parameters must be
[0...getArity() - 1]
.ArrayOutOfBoundsException
- if i >= getArity()
.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.