public class DataTypeManager extends 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.
TODO: refactor the string/class/code into an enumModifier and Type | Class and Description |
---|---|
static class |
DataTypeManager.DataTypeAliases |
static class |
DataTypeManager.DefaultDataClasses |
static class |
DataTypeManager.DefaultDataTypes |
static class |
DataTypeManager.DefaultTypeCodes |
static class |
DataTypeManager.WeakReferenceHashedValueCache<T> |
Modifier and Type | Field and Description |
---|---|
static String |
ARRAY_SUFFIX |
static String |
COLLATION_LOCALE |
static String |
DEFAULT_COLLATION |
static int |
MAX_LOB_MEMORY_BYTES |
static int |
MAX_STRING_LENGTH |
static int |
MAX_TYPE_CODE |
static int |
MAX_VARBINARY_BYTES |
static boolean |
PAD_SPACE |
static boolean |
USE_VALUE_CACHE |
Modifier and Type | Method and Description |
---|---|
static Object |
convertToRuntimeType(Object value,
boolean allConversions)
Convert the value to the probable runtime type.
|
static Class<?> |
determineDataTypeClass(Object value)
Take an object and determine the MetaMatrix data type.
|
static Set<Class<?>> |
getAllDataTypeClasses() |
static Set<String> |
getAllDataTypeNames()
Get a set of all data type names.
|
static Class<?> |
getArrayType(Class<?> classType) |
static String |
getCanonicalString(String value) |
static <T> T |
getCanonicalValue(T value) |
static Class<?> |
getClass(int code) |
static String |
getComponentType(String srcType) |
static Class<?> |
getDataTypeClass(String name)
Get data type class.
|
static String |
getDataTypeName(Class<?> typeClass) |
static void |
getImplicitConversions(String type,
Collection<String> result) |
static Class<?> |
getRuntimeType(Class<?> c) |
static Transform |
getTransform(Class<?> sourceType,
Class<?> targetType)
Get a data value transformation between the sourceType and the
targetType.
|
static Transform |
getTransform(String sourceTypeName,
String targetTypeName)
Get a data value transformation between the sourceType with given name
and the targetType of given name.
|
static int |
getTypeCode(Class<?> source) |
static boolean |
hasLength(String typeName)
Return true if the type may be defined with a length
|
static boolean |
isArrayType(String name) |
static boolean |
isExplicitConversion(String srcType,
String tgtType) |
static boolean |
isHashable(Class<?> type) |
static boolean |
isImplicitConversion(String srcType,
String tgtType) |
static boolean |
isLOB(Class<?> type)
Is the supplied class type a LOB based data type?
|
static boolean |
isLOB(String type) |
static boolean |
isNonComparable(String type) |
static boolean |
isTransformable(Class<?> sourceType,
Class<?> targetType)
Does a transformation exist between the source and target type?
|
static boolean |
isTransformable(String sourceTypeName,
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 boolean |
isValueCacheEnabled() |
static int |
nextPowOf2(int val) |
static void |
setValueCacheEnabled(boolean enabled) |
static Object |
transformValue(Object value,
Class<?> targetClass) |
static Object |
transformValue(Object value,
Class<?> sourceType,
Class<?> targetClass) |
public static final String ARRAY_SUFFIX
public static final boolean USE_VALUE_CACHE
public static final boolean PAD_SPACE
public static final String DEFAULT_COLLATION
public static final String COLLATION_LOCALE
public static final int MAX_STRING_LENGTH
public static final int MAX_VARBINARY_BYTES
public static final int MAX_LOB_MEMORY_BYTES
public static final int MAX_TYPE_CODE
public static int nextPowOf2(int val)
public static int getTypeCode(Class<?> source)
public static Class<?> getClass(int code)
public static Set<String> getAllDataTypeNames()
public static Class<?> getDataTypeClass(String name)
name
- Data type namepublic static boolean isArrayType(String name)
public static Class<?> determineDataTypeClass(Object value)
public static Transform getTransform(Class<?> sourceType, Class<?> targetType)
sourceType
- Incoming value typetargetType
- Outgoing value typepublic static Transform getTransform(String sourceTypeName, String targetTypeName)
sourceTypeName
- Incoming value type nametargetTypeName
- Outgoing value type namepublic static boolean isTransformable(Class<?> sourceType, Class<?> targetType)
sourceType
- Incoming value typetargetType
- Outgoing value typepublic static boolean isTransformable(String sourceTypeName, String targetTypeName)
sourceTypeName
- Incoming value type nametargetTypeName
- Outgoing value type namepublic static void getImplicitConversions(String type, Collection<String> result)
public static boolean isLOB(Class<?> type)
type
- public static boolean isLOB(String type)
public static Object convertToRuntimeType(Object value, boolean allConversions)
allConversions
- if false only lob conversions will be usedpublic static Object transformValue(Object value, Class<?> targetClass) throws TransformationException
TransformationException
public static Object transformValue(Object value, Class<?> sourceType, Class<?> targetClass) throws TransformationException
TransformationException
public static boolean isNonComparable(String type)
public static void setValueCacheEnabled(boolean enabled)
public static final boolean isValueCacheEnabled()
public static final <T> T getCanonicalValue(T value)
public static boolean isHashable(Class<?> type)
public static boolean hasLength(String typeName)
Copyright © 2019. All rights reserved.