org.hypergraphdb.type
Class RecordType

java.lang.Object
  extended by org.hypergraphdb.type.RecordType
All Implemented Interfaces:
HGGraphHolder, HGAtomType, HGCompositeType

public class RecordType
extends java.lang.Object
implements HGCompositeType

A RecordType represents a particular combination of slots that can be used to construct records. The latter are instances of Record.

It is important that the slots in a record type are maintained in an order matching the HG store layout of record values.

Author:
Borislav Iordanov

Constructor Summary
RecordType()
           
 
Method Summary
 void addSlot(HGHandle slot)
           
 boolean equals(java.lang.Object other)
           
 HGHandle getAt(int i)
           
 java.util.Iterator<java.lang.String> getDimensionNames()
          Return an Iterator listing the names of all dimensions of this composite type.
 HGProjection getProjection(java.lang.String dimensionName)
          Get the projection function for a particular dimension.
 HGAtomRef.Mode getReferenceMode(HGHandle slot)
           
 java.util.List<HGHandle> getSlots()
           
 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.
 void remove(HGHandle slot)
           
 void removeAt(int i)
           
 void setHyperGraph(HyperGraph hg)
          During load time, set the HyperGraph instance to which this atom belongs.
 void setThisHandle(HGHandle thisHandle)
           
 int slotCount()
           
 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 generic semantic predicate that returns true if the first argument is more general than the second.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RecordType

public RecordType()
Method Detail

getReferenceMode

public HGAtomRef.Mode getReferenceMode(HGHandle slot)

setThisHandle

public void setThisHandle(HGHandle thisHandle)

getDimensionNames

public java.util.Iterator<java.lang.String> getDimensionNames()
Description copied from interface: HGCompositeType

Return an Iterator listing the names of all dimensions of this composite type. A projection function can be obtained through the getProjection method.

Specified by:
getDimensionNames in interface HGCompositeType

getProjection

public HGProjection getProjection(java.lang.String dimensionName)
Description copied from interface: HGCompositeType

Get the projection function for a particular dimension.

Specified by:
getProjection in interface HGCompositeType
Parameters:
dimensionName - The name of the dimension.
Returns:
The HGProjection instance.

getSlots

public java.util.List<HGHandle> getSlots()

addSlot

public void addSlot(HGHandle slot)

remove

public void remove(HGHandle slot)

removeAt

public void removeAt(int i)

getAt

public HGHandle getAt(int i)

slotCount

public int slotCount()

setHyperGraph

public void setHyperGraph(HyperGraph hg)
Description copied from interface: HGGraphHolder

During load time, set the HyperGraph instance to which this atom belongs.

Specified by:
setHyperGraph in interface HGGraphHolder

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)
Description copied from interface: HGAtomType

A generic semantic predicate that returns true if the first argument is more general than the second. Atom types must implement this notion of specialization whenever meaningful in the context of the entities being constructed.

The notion of subsumption can be seen as partial equivalence, or equivalence in one direction only.

As a relation, subsumtion is transitive and reflexive. The latter implies that, at a minimum, the subsumes method must return true if general.equals(specific).

Specified by:
subsumes in interface HGAtomType
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.

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object