com.metamatrix.common.types
Class DataTypeManager

java.lang.Object
  extended by com.metamatrix.common.types.DataTypeManager

public class DataTypeManager
extends java.lang.Object

This class manages data type, conversions between data types, and comparators for data types. In the future other data type information may be managed here.

In general, methods are provided to refer to types either by Class, or by Class name. The benefit of the Class name option is that the user does not need to load the Class object, which may not be in the classpath. The advantage of the Class option is speed.


Nested Class Summary
static class DataTypeManager.DefaultDataClasses
           
static class DataTypeManager.DefaultDataTypes
           
 
Field Summary
static int MAX_STRING_LENGTH
           
 
Method Summary
static java.lang.Object convertToRuntimeType(java.lang.Object value)
           
static java.lang.Class determineDataTypeClass(java.lang.Object value)
          Take an object and determine the MetaMatrix data type.
static java.util.Set<java.lang.Class> getAllDataTypeClasses()
           
static java.util.Set<java.lang.String> getAllDataTypeNames()
          Get a set of all data type names.
static java.lang.Class getDataTypeClass(java.lang.String name)
          Get data type class.
static java.lang.String getDataTypeName(java.lang.Class typeClass)
           
static java.util.List<java.lang.String> getImplicitConversions(java.lang.String type)
           
static Transform getTransform(java.lang.Class sourceType, java.lang.Class targetType)
          Get a data value transformation between the sourceType and the targetType.
static Transform getTransform(java.lang.String sourceTypeName, java.lang.String targetTypeName)
          Get a data value transformation between the sourceType with given name and the targetType of given name.
static boolean isExplicitConversion(java.lang.String srcType, java.lang.String tgtType)
           
static boolean isImplicitConversion(java.lang.String srcType, java.lang.String tgtType)
           
static boolean isLOB(java.lang.Class type)
          Is the supplied class type a LOB based data type?
static boolean isLOB(java.lang.String type)
           
static boolean isNonComparable(java.lang.String type)
           
static boolean isTransformable(java.lang.Class sourceType, java.lang.Class targetType)
          Does a transformation exist between the source and target type?
static boolean isTransformable(java.lang.String sourceTypeName, java.lang.String targetTypeName)
          Does a transformation exist between the source and target type of given names? The Class for source and target type are not needed to do this lookup.
static
<T> T
transformValue(java.lang.Object value, java.lang.Class<T> targetClass)
           
static
<T> T
transformValue(java.lang.Object value, java.lang.Class sourceType, java.lang.Class<T> targetClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_STRING_LENGTH

public static final int MAX_STRING_LENGTH
See Also:
Constant Field Values
Method Detail

getAllDataTypeNames

public static java.util.Set<java.lang.String> getAllDataTypeNames()
Get a set of all data type names.

Returns:
Set of data type names (String)

getAllDataTypeClasses

public static java.util.Set<java.lang.Class> getAllDataTypeClasses()

getDataTypeClass

public static java.lang.Class getDataTypeClass(java.lang.String name)
Get data type class.

Parameters:
name - Data type name
Returns:
Data type class

getDataTypeName

public static java.lang.String getDataTypeName(java.lang.Class typeClass)

determineDataTypeClass

public static java.lang.Class determineDataTypeClass(java.lang.Object value)
Take an object and determine the MetaMatrix data type. In most cases, this is simply the class of the object. Some special cases are when the value is of type Object or Null.


getTransform

public static Transform getTransform(java.lang.Class sourceType,
                                     java.lang.Class targetType)
Get a data value transformation between the sourceType and the targetType.

Parameters:
sourceType - Incoming value type
targetType - Outgoing value type
Returns:
A transform if one exists, null otherwise

getTransform

public static Transform getTransform(java.lang.String sourceTypeName,
                                     java.lang.String targetTypeName)
Get a data value transformation between the sourceType with given name and the targetType of given name. The Class for source and target type are not needed to do this lookup.

Parameters:
sourceTypeName - Incoming value type name
targetTypeName - Outgoing value type name
Returns:
A transform if one exists, null otherwise

isTransformable

public static boolean isTransformable(java.lang.Class sourceType,
                                      java.lang.Class targetType)
Does a transformation exist between the source and target type?

Parameters:
sourceType - Incoming value type
targetType - Outgoing value type
Returns:
True if a transform exists

isTransformable

public static boolean isTransformable(java.lang.String sourceTypeName,
                                      java.lang.String targetTypeName)
Does a transformation exist between the source and target type of given names? The Class for source and target type are not needed to do this lookup.

Parameters:
sourceTypeName - Incoming value type name
targetTypeName - Outgoing value type name
Returns:
True if a transform exists

getImplicitConversions

public static java.util.List<java.lang.String> getImplicitConversions(java.lang.String type)

isImplicitConversion

public static boolean isImplicitConversion(java.lang.String srcType,
                                           java.lang.String tgtType)

isExplicitConversion

public static boolean isExplicitConversion(java.lang.String srcType,
                                           java.lang.String tgtType)

isLOB

public static boolean isLOB(java.lang.Class type)
Is the supplied class type a LOB based data type?

Parameters:
type -
Returns:
true if yes; false otherwise

isLOB

public static boolean isLOB(java.lang.String type)

convertToRuntimeType

public static java.lang.Object convertToRuntimeType(java.lang.Object value)

transformValue

public static <T> T transformValue(java.lang.Object value,
                                   java.lang.Class<T> targetClass)
                        throws TransformationException
Throws:
TransformationException

transformValue

public static <T> T transformValue(java.lang.Object value,
                                   java.lang.Class sourceType,
                                   java.lang.Class<T> targetClass)
                        throws TransformationException
Throws:
TransformationException

isNonComparable

public static boolean isNonComparable(java.lang.String type)


Copyright © 2009. All Rights Reserved.