org.hypergraphdb.atom
Class HGRelTypeConstructor

java.lang.Object
  extended by org.hypergraphdb.type.HGAtomTypeBase
      extended by org.hypergraphdb.atom.HGRelTypeConstructor
All Implemented Interfaces:
HGGraphHolder, HGSearchable<HGRelType,HGPersistentHandle>, HGAtomType

public class HGRelTypeConstructor
extends HGAtomTypeBase
implements HGSearchable<HGRelType,HGPersistentHandle>

The type of HGRelType. Even though we could have treated HGRelType, that would have created different RecordType which would have made it harder working purely with HGRelationships outside of Java (since one would have to get to the RecordType by querying on the class name). In any case, a HGRelType is conceptually not really a record...

Author:
Borislav Iordanov

Field Summary
static java.lang.String INDEX_NAME
           
 
Constructor Summary
HGRelTypeConstructor()
           
 
Method Summary
 HGSearchResult<HGPersistentHandle> find(HGRelType key)
           Returns a HGSearchResult over all values matching a key in the searched entity.
 java.lang.Object make(HGPersistentHandle handle, LazyRef<HGHandle[]> targetSet, IncidenceSetRef incidenceSet)
          Construct a new run-time instance of a hypergraph atom.
 void release(HGPersistentHandle handle)
          Release a hypergraph value instance from the persistent store.
 HGPersistentHandle store(java.lang.Object instance)
          Store a run-time instance of a hypergraph atom into the hypergraph HGStore as a new atom.
 boolean subsumes(java.lang.Object general, java.lang.Object specific)
           A HGRelType X subsumes a HGRelType Y iff both have the same name and arity and each target atom of X subsumes the corresponding target atom of Y.
 
Methods inherited from class org.hypergraphdb.type.HGAtomTypeBase
getHyperGraph, setHyperGraph
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEX_NAME

public static final java.lang.String INDEX_NAME
See Also:
Constant Field Values
Constructor Detail

HGRelTypeConstructor

public HGRelTypeConstructor()
Method Detail

make

public java.lang.Object make(HGPersistentHandle handle,
                             LazyRef<HGHandle[]> targetSet,
                             IncidenceSetRef incidenceSet)
Description copied from interface: 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 HGLinks. 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.

Specified by:
make in interface HGAtomType
Parameters:
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 - TODO
Returns:
The run-time atom instance. The return value should never be null. In case the handle points to an invalid instance (inexisting or with a erronous layout), the method should throw a HGException.

store

public HGPersistentHandle store(java.lang.Object instance)
Description copied from interface: HGAtomType

Store a run-time instance of a hypergraph atom into the hypergraph HGStore as a new atom.

Specified by:
store in interface HGAtomType
Parameters:
instance - The atom instance.
Returns:
The persistent handle of the stored value.

release

public void release(HGPersistentHandle handle)
Description copied from interface: 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.

Specified by:
release in interface HGAtomType
Parameters:
handle - The persistent handle of the value to release.

subsumes

public boolean subsumes(java.lang.Object general,
                        java.lang.Object specific)

A HGRelType X subsumes a HGRelType Y iff both have the same name and arity and each target atom of X subsumes the corresponding target atom of Y.

In plain language this reflects the logical requirement that each instance relationship with type Y be also an instance (logically) of X.

Specified by:
subsumes in interface HGAtomType
Overrides:
subsumes in class HGAtomTypeBase
Parameters:
general - The object which might be more general. Cannot be null.
specific - The object which might be more specific. Cannot be null.
Returns:
true if specific can be used whenever general is required and false otherwise.

find

public HGSearchResult<HGPersistentHandle> find(HGRelType key)
Description copied from interface: HGSearchable

Returns a HGSearchResult over all values matching a key in the searched entity.

If there are no matches, the method should return HGSearchResult.EMPTY. The method will never return a null. A HGException may be thrown in exceptional situations.

Specified by:
find in interface HGSearchable<HGRelType,HGPersistentHandle>