org.hypergraphdb.util
Class TempLink

java.lang.Object
  extended by org.hypergraphdb.util.TempLink
All Implemented Interfaces:
HGLink

public class TempLink
extends java.lang.Object
implements HGLink

This class represents a simple, temporary link used during various query and graph traversal activities. It is just a HGLink wrapper around an array of HGHandles. It is needed by APIs that rely solely on the HGLink interface, but need to work with temporary link representations in the frorm of HGHandle[].

Note that the implementation never checks for null when accessing its HGHandle array argument.

Author:
Borislav Iordanov

Constructor Summary
TempLink(HGHandle[] array)
           
TempLink(HGHandle[] array, int start)
           
TempLink(HGHandle[] array, int start, int end)
           
 
Method Summary
 int getArity()
          Return the number of targets of this link.
 HGHandle getTargetAt(int i)
          Return the ith target.
 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 setHandleArray(HGHandle[] array)
           
 void setHandleArray(HGHandle[] array, int start)
           
 void setHandleArray(HGHandle[] array, int start, int end)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TempLink

public TempLink(HGHandle[] array)

TempLink

public TempLink(HGHandle[] array,
                int start)

TempLink

public TempLink(HGHandle[] array,
                int start,
                int end)
Method Detail

setHandleArray

public void setHandleArray(HGHandle[] array)

setHandleArray

public void setHandleArray(HGHandle[] array,
                           int start)

setHandleArray

public void setHandleArray(HGHandle[] array,
                           int start,
                           int end)

getArity

public int getArity()
Description copied from interface: HGLink

Return the number of targets of this link. This number may be >= 0.

Specified by:
getArity in interface HGLink

getTargetAt

public HGHandle getTargetAt(int i)
Description copied from interface: HGLink

Return the ith target.

Specified by:
getTargetAt in interface HGLink
Parameters:
i - The index of the desired target. The range of this parameters must be [0...getArity() - 1].

notifyTargetHandleUpdate

public void notifyTargetHandleUpdate(int i,
                                     HGHandle handle)
Description copied from interface: 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.

Specified by:
notifyTargetHandleUpdate in interface HGLink
Parameters:
i - The index of the target that was loaded.
handle - The new live handle of the target atom.

notifyTargetRemoved

public void notifyTargetRemoved(int i)
Description copied from interface: 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 in otherwise inconsistent state. Throwing such an exception would indicate a fatal error and a very likely bug in the application.

Specified by:
notifyTargetRemoved in interface HGLink
Parameters:
i - The 0-based position of the target to be removed from this link.