org.hypergraphdb.type
Class JavaTypeFactory

java.lang.Object
  extended by org.hypergraphdb.type.JavaTypeFactory
All Implemented Interfaces:
HGGraphHolder, JavaTypeMapper

public class JavaTypeFactory
extends java.lang.Object
implements JavaTypeMapper

The JavaTypeFactory is used to infer HyperGraph types based on Java beans. Java bean classes are converted to instances of RecordType and Java bean instances to the corresponding Records. Only properties that are both readable and writeable are mapped to HyperGraph Slots.

Author:
Borislav Iordanov

Constructor Summary
JavaTypeFactory()
           
 
Method Summary
 void assign(java.lang.Object bean, java.lang.String property, java.lang.Object value)
           
 void assignPrivate(java.lang.Class<?> clazz, java.lang.Object x, java.lang.String field, java.lang.Object value)
           
 HGAtomType defineHGType(java.lang.Class<?> javaClass, HGHandle typeHandle)
           Create a new HyperGraphDB type for the given Java class.
 DefaultJavaTypeMapper getDefaultJavaMapper()
           
 HGAtomType getJavaBinding(HGHandle typeHandle, HGAtomType hgType, java.lang.Class<?> javaClass)
           Create a type wrapper for a given raw HyperGraphDB type.
 JavaObjectMapper getJavaObjectMapper()
           
 java.util.List<JavaTypeMapper> getMappers()
           
 HGHandle getSlotHandle(java.lang.String label, HGHandle type)
           
 void initNonDefaultMappers()
           
static boolean isAbstract(java.lang.Class<?> c)
           
static boolean isDefaultConstructible(java.lang.Class<?> c)
           
static boolean isHGInstantiable(java.lang.Class<?> c)
           
static boolean isLink(java.lang.Class<?> c)
           
 java.lang.Object retrievePrivate(java.lang.Class<?> clazz, java.lang.Object x, java.lang.String field)
           
 void setHyperGraph(HyperGraph graph)
          During load time, set the HyperGraph instance to which this atom belongs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaTypeFactory

public JavaTypeFactory()
Method Detail

initNonDefaultMappers

public void initNonDefaultMappers()

assign

public void assign(java.lang.Object bean,
                   java.lang.String property,
                   java.lang.Object value)

assignPrivate

public void assignPrivate(java.lang.Class<?> clazz,
                          java.lang.Object x,
                          java.lang.String field,
                          java.lang.Object value)

retrievePrivate

public java.lang.Object retrievePrivate(java.lang.Class<?> clazz,
                                        java.lang.Object x,
                                        java.lang.String field)

isAbstract

public static boolean isAbstract(java.lang.Class<?> c)

isDefaultConstructible

public static boolean isDefaultConstructible(java.lang.Class<?> c)

isLink

public static boolean isLink(java.lang.Class<?> c)

isHGInstantiable

public static boolean isHGInstantiable(java.lang.Class<?> c)

getSlotHandle

public HGHandle getSlotHandle(java.lang.String label,
                              HGHandle type)

defineHGType

public HGAtomType defineHGType(java.lang.Class<?> javaClass,
                               HGHandle typeHandle)
Description copied from interface: JavaTypeMapper

Create a new HyperGraphDB type for the given Java class. The HGHandle of the type pre-created and provided as a parameter.

This method should return a brand new HGAtomType that will subsequently be saved as a type atom with handle typeHandle and associated with the javaClass class.

Specified by:
defineHGType in interface JavaTypeMapper
Returns:

getJavaBinding

public HGAtomType getJavaBinding(HGHandle typeHandle,
                                 HGAtomType hgType,
                                 java.lang.Class<?> javaClass)
Description copied from interface: JavaTypeMapper

Create a type wrapper for a given raw HyperGraphDB type. The type wrapper should work with the regular Java runtime instance of an atom and use the underlying HG type for actual storage and retrieval.

Specified by:
getJavaBinding in interface JavaTypeMapper
Returns:

setHyperGraph

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

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

Specified by:
setHyperGraph in interface HGGraphHolder

getDefaultJavaMapper

public DefaultJavaTypeMapper getDefaultJavaMapper()

getJavaObjectMapper

public JavaObjectMapper getJavaObjectMapper()

getMappers

public java.util.List<JavaTypeMapper> getMappers()