public class JavaTypeSchema extends Object implements HGTypeSchema<Class<?>>
Modifier and Type | Class and Description |
---|---|
class |
JavaTypeSchema.ClassToTypeCache |
Constructor and Description |
---|
JavaTypeSchema() |
JavaTypeSchema(HyperGraph graph) |
Modifier and Type | Method and Description |
---|---|
static URI |
classNameToURI(String classname) |
static URI |
classToURI(Class<?> cl) |
void |
defineType(URI typeId,
HGHandle typeHandle)
Construct a new HyperGraphDB type from the specified type identifier
URI . |
HGAtomType |
defineType(URI typeId,
HGHandle typeHandle,
Class<?> descriptor) |
HGHandle |
findType(Class<?> clazz) |
HGHandle |
findType(URI typeId)
Return the
HGHandle of an existing HyperGraph type that corresponds
to the specified type identifier according to this schema. |
HGAtomType |
fromRuntimeType(HGHandle typeHandle,
HGAtomType typeInstance)
If a given type is wrapped under a different runtime representation by
the
HGTypeSchema.toRuntimeType(HGHandle, HGAtomType) method, this method
retrieves the underlying default representation as constructed by the
type system. |
JavaTypeMapper |
getJavaTypeFactory() |
String |
getName()
Return the name of this
HGTypeSchema . |
String |
getPredefinedTypes()
Return the location of the type configuration file.
|
Class<?> |
getTypeDescriptor(URI typeId)
Return the
TypeDescriptor corresponding to the passed in type
identifier. |
void |
initialize(HyperGraph graph)
Initialize the schema with the
HyperGraph instance to which it is bound. |
boolean |
isPresent(HyperGraph graph) |
void |
removeType(URI typeId) |
void |
setPredefinedTypes(String predefinedTypes)
Specify the type configuration file to use when bootstrapping the type system.
|
HGAtomType |
toRuntimeType(HGHandle typeHandle,
HGAtomType typeInstance)
The type schema may wrap a given HyperGraphDB type into a different
runtime instance.
|
URI |
toTypeURI(Class<?> javaClass) |
URI |
toTypeURI(Object object) |
static String |
uriToClassName(URI uri) |
public JavaTypeSchema()
public JavaTypeSchema(HyperGraph graph)
public JavaTypeMapper getJavaTypeFactory()
public String getPredefinedTypes()
Return the location of the type configuration file. This file can be either a classpath resource or a file on disk or
public void setPredefinedTypes(String predefinedTypes)
Specify the type configuration file to use when bootstrapping the type system. This file
must contain the list of predefined types needed for the normal functioning of a database
instance. Each line in this text file is a space separated list of (1) the persistent handle
of the type (2) The Java class implementing the HGAtomType
interface and optionally
(3) one or more Java classes to which the type implementation is associated.
typeConfiguration
- The location of the type configuration file. First, an attempt
is made to load this location is a classpath resource. Then as a local file. Finally as
a remote URL-based resource.public String getName()
HGTypeSchema
Return the name of this HGTypeSchema
. The name of a type
schema uniquely identifies it.
getName
in interface HGTypeSchema<Class<?>>
public boolean isPresent(HyperGraph graph)
public void initialize(HyperGraph graph)
HGTypeSchema
Initialize the schema with the HyperGraph
instance to which it is bound.
A given schema runtime instance is only bound to one database instance.
initialize
in interface HGTypeSchema<Class<?>>
public HGAtomType defineType(URI typeId, HGHandle typeHandle, Class<?> descriptor)
public Class<?> getTypeDescriptor(URI typeId)
HGTypeSchema
Return the TypeDescriptor
corresponding to the passed in type
identifier.
getTypeDescriptor
in interface HGTypeSchema<Class<?>>
public HGAtomType toRuntimeType(HGHandle typeHandle, HGAtomType typeInstance)
HGTypeSchema
The type schema may wrap a given HyperGraphDB type into a different
runtime instance. This is useful when atoms, and therefore in all likelihood
their types as well, have different runtime representations depending on
the current type schema in effect. Every time a type is loaded by the type
system, the toRuntimeType
of the current type schema is called
to give it a change to provide a different representation.
toRuntimeType
in interface HGTypeSchema<Class<?>>
typeHandle
- The HGHandle
of the type.typeInstance
- The type instance constructed by default from the
type system.public HGAtomType fromRuntimeType(HGHandle typeHandle, HGAtomType typeInstance)
HGTypeSchema
If a given type is wrapped under a different runtime representation by
the HGTypeSchema.toRuntimeType(HGHandle, HGAtomType)
method, this method
retrieves the underlying default representation as constructed by the
type system.
fromRuntimeType
in interface HGTypeSchema<Class<?>>
typeHandle
- The HGHandle
of the type.typeInstance
- A modified runtime representation of the type.public URI toTypeURI(Object object)
toTypeURI
in interface HGTypeSchema<Class<?>>
public HGHandle findType(URI typeId)
HGTypeSchema
Return the HGHandle
of an existing HyperGraph type that corresponds
to the specified type identifier according to this schema.
findType
in interface HGTypeSchema<Class<?>>
typeId
- The identifier of the type. The identifier must be valid
within this schema. In particular the schema part of the URI must match
this schema's name.HGHandle
of the HyperGraph type if it exists or null
if it doesn't.public void removeType(URI typeId)
removeType
in interface HGTypeSchema<Class<?>>
public URI toTypeURI(Class<?> javaClass)
toTypeURI
in interface HGTypeSchema<Class<?>>
public void defineType(URI typeId, HGHandle typeHandle)
HGTypeSchema
Construct a new HyperGraphDB type from the specified type identifierURI
.
It is the responsibility of the schema implementation to find the correct
TypeDescriptor
for that identifier. The schema may return an existing
HyperGraph type that corresponds to the identifier is it finds one already
in the database. However, types, like other atoms, are not guaranteed to be
immutable. Therefore, a schema does not "own" a HyperGraph type and the latter
may be modified outside of its control.
defineType
in interface HGTypeSchema<Class<?>>
typeId
- The identifier of the type. The identifier must be valid
within this schema. In particular the schema part of the URI must match
this schema's name.Copyright © 2015. All rights reserved.