org.datanucleus.store.types
Class TypeManager

java.lang.Object
  extended by org.datanucleus.store.types.TypeManager

public class TypeManager
extends java.lang.Object

Registry of java type support. Provides information applicable to all datastores for how a field of a class is treated; whether it is by default persistent, whether it is by default embedded, whether it is in the DFG, and if it has a wrapper for SCO operations. Also stores whether the type can be converted to/from a String (for datastores that don't provide storage natively). Uses the plugin mechanism extension-point "org.datanucleus.java_type". TODO Consider adding "api" as an attribute to the "java_type" extension-point so that we can have some a type definition for JDO, and also for JPA.


Field Summary
protected  ClassLoaderResolver clr
           
 
Constructor Summary
TypeManager(ApiAdapter api, PluginManager mgr, ClassLoaderResolver clr)
          Constructor, loading support for type mappings using the plugin mechanism.
 
Method Summary
protected  void addJavaType(org.datanucleus.store.types.TypeManager.JavaType type, java.lang.String javaVersion, boolean versionRestricted)
           
 java.lang.String[] filterOutSupportedSecondClassNames(java.lang.String[] inputClassNames)
          Convenience method to filter out any supported classes from a list.
protected  org.datanucleus.store.types.TypeManager.JavaType findJavaTypeForClass(java.lang.Class cls)
          Convenience method to return the JavaType for the specified class.
 ObjectStringConverter getStringConverter(java.lang.Class type)
          Method to return a string converter for the specified type.
 java.util.Set getSupportedSecondClassTypes()
          Accessor for the supported second-class Types.
 java.lang.Class getTypeForSecondClassWrapper(java.lang.String className)
          Accessor for a java type that the supplied class is a SCO wrapper for.
 java.lang.Class getWrappedTypeBackedForType(java.lang.String className)
          Accessor for the backing-store Second Class Wrapper class for the supplied class.
 java.lang.Class getWrapperTypeForType(java.lang.String className)
          Accessor for the SCO wrapper for the type
 boolean isDefaultEmbeddedType(java.lang.Class c)
          Accessor for whether the type is by default embedded.
 boolean isDefaultFetchGroup(java.lang.Class c)
          Accessor for whether the type is by default in the DFG.
 boolean isDefaultPersistent(java.lang.Class c)
          Accessor for whether the type is by default persistent.
 boolean isSecondClassMutableType(java.lang.String className)
          Accessor for whether the type is SCO mutable.
 boolean isSecondClassWrapper(java.lang.String className)
          Accessor for whether the type is a SCO wrapper itself.
 boolean isSupportedSecondClassType(java.lang.String className)
          Accessor for whether a class is supported as being second class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clr

protected final ClassLoaderResolver clr
Constructor Detail

TypeManager

public TypeManager(ApiAdapter api,
                   PluginManager mgr,
                   ClassLoaderResolver clr)
Constructor, loading support for type mappings using the plugin mechanism.

Parameters:
api - The API in use // NEVER USED currently
clr - the ClassLoader Resolver
mgr - the PluginManager
Method Detail

getSupportedSecondClassTypes

public java.util.Set getSupportedSecondClassTypes()
Accessor for the supported second-class Types. This may or may not be a complete list, just that it provides the principal ones.

Returns:
Set of supported types (fully qualified class names).

isSupportedSecondClassType

public boolean isSupportedSecondClassType(java.lang.String className)
Accessor for whether a class is supported as being second class.

Parameters:
className - The class name
Returns:
Whether the class is supported (to some degree)

filterOutSupportedSecondClassNames

public java.lang.String[] filterOutSupportedSecondClassNames(java.lang.String[] inputClassNames)
Convenience method to filter out any supported classes from a list.

Parameters:
inputClassNames - Names of the classes
Returns:
Names of the classes (omitting supported types)

isDefaultPersistent

public boolean isDefaultPersistent(java.lang.Class c)
Accessor for whether the type is by default persistent.

Parameters:
c - The type
Returns:
Whether persistent

isDefaultFetchGroup

public boolean isDefaultFetchGroup(java.lang.Class c)
Accessor for whether the type is by default in the DFG.

Parameters:
c - The type
Returns:
Whether in the DFG

isDefaultEmbeddedType

public boolean isDefaultEmbeddedType(java.lang.Class c)
Accessor for whether the type is by default embedded.

Parameters:
c - The type
Returns:
Whether embedded

isSecondClassMutableType

public boolean isSecondClassMutableType(java.lang.String className)
Accessor for whether the type is SCO mutable.

Parameters:
className - The type
Returns:
Whether SCO mutable

getWrapperTypeForType

public java.lang.Class getWrapperTypeForType(java.lang.String className)
Accessor for the SCO wrapper for the type

Parameters:
className - The type
Returns:
SCO wrapper

getWrappedTypeBackedForType

public java.lang.Class getWrappedTypeBackedForType(java.lang.String className)
Accessor for the backing-store Second Class Wrapper class for the supplied class. A type will have a SCO wrapper if it is SCO supported and is mutable. If there is no backed wrapper provided returns the simple wrapper.

Parameters:
className - The class name
Returns:
The second class wrapper

isSecondClassWrapper

public boolean isSecondClassWrapper(java.lang.String className)
Accessor for whether the type is a SCO wrapper itself.

Parameters:
className - The type
Returns:
Whether is SCO wrapper

getTypeForSecondClassWrapper

public java.lang.Class getTypeForSecondClassWrapper(java.lang.String className)
Accessor for a java type that the supplied class is a SCO wrapper for. If the supplied class is not a SCO wrapper for anything then returns null.

Parameters:
className - Name of the class
Returns:
The java class that this is a wrapper for (or null)

getStringConverter

public ObjectStringConverter getStringConverter(java.lang.Class type)
Method to return a string converter for the specified type. Returns an instance of the converter (implementation of ObjectStringConverter) or null if not mappable as a String.

Parameters:
type - The type
Returns:
The string converter (or null)

findJavaTypeForClass

protected org.datanucleus.store.types.TypeManager.JavaType findJavaTypeForClass(java.lang.Class cls)
Convenience method to return the JavaType for the specified class. If this class has a defined JavaType then returns it. If not then tries to find a superclass that is castable to the specified type.

Parameters:
cls - The class required
Returns:
The JavaType

addJavaType

protected void addJavaType(org.datanucleus.store.types.TypeManager.JavaType type,
                           java.lang.String javaVersion,
                           boolean versionRestricted)


Copyright © 2009. All Rights Reserved.