Class TypeSupport
- java.lang.Object
-
- com.sun.jdo.spi.persistence.support.ejb.ejbqlc.TypeSupport
-
public class TypeSupport extends Object
Helper class to support type info access. A type info is statically an object, internally the helper uses the type name as type info. The helper uses a model instance to access meta model info and uses a NameMapper to map EJB names to JDO names and vice versa.- Author:
- Michael Bouschen, Shing Wai Chan
-
-
Field Summary
Fields Modifier and Type Field Description static ObjectbigDecimalTypeRepresents the type java.math.BigDecimal.static ObjectbigIntegerTypeRepresents the type java.math.BigInteger.static ObjectbooleanClassTypeRepresents the wrapper class type boolean.static ObjectbooleanTypeRepresents the primitive type boolean.static ObjectbyteClassTypeRepresents the wrapper class type byte.static ObjectbyteTypeRepresents the primitive type byte.static ObjectcharacterClassTypeRepresents the wrapper class type char.static ObjectcharTypeRepresents the primitive type char.protected static SetdateTimeTypesSet of names of date and time types.static ObjectdoubleClassTypeRepresents the wrapper class type double.static ObjectdoubleTypeRepresents the primitive type double.static ObjecterrorTypeRepresents the internal error type.static ObjectfloatClassTypeRepresents the wrapper class type float.static ObjectfloatTypeRepresents the primitive type float.static ObjectintegerClassTypeRepresents the wrapper class type int.static ObjectintTypeRepresents the primitive type int.static ObjectlongClassTypeRepresents the wrapper class type long.static ObjectlongTypeRepresents the primitive type long.protected ModelmodelMeta data access.protected static ResourceBundlemsgsI18N support.protected NameMappernameMapperName mapping EJB <-> JDO.protected static SetnumericTypesSet of names of numeric types.protected static SetnumericWrapperTypesSet of names of numeric wrapper classes.static ObjectshortClassTypeRepresents the wrapper class type short.static ObjectshortTypeRepresents the primitive type short.static ObjectstringTypeRepresents the type java.lang.String.
-
Constructor Summary
Constructors Constructor Description TypeSupport(Model model, NameMapper nameMapper)Creates a new TypeSupport using the specified model instance to access meta data and the specified nameMapper for EJB <-> JDO name mapping.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ObjectbinaryNumericPromotion(Object left, Object right)Implements binary numeric promotion as defined in the Java Language Specification section 5.6.2StringgetAbstractSchemaForTypeInfo(Object typeInfo)Returns the typeInfo (the ejb name) for the specified abstract schema.ObjectgetAvgReturnType(Object type)Return JDO QL return type for Avg function for a given type.ObjectgetElementType(Object fieldInfo)Returns the type info of the element type if the specified field info denotes a collection relationship.ObjectgetFieldInfo(Object typeInfo, String fieldName)Returns the field info for the specified field of the specified type.ObjectgetFieldType(Object typeInfo, String fieldName)Returns the type info for the type of the given field.ObjectgetMinMaxReturnType(Object type)Return JDO QL return type for Min/Max function for a given type.StringgetPCForTypeInfo(Object typeInfo)Gets the name of the persistence-capable class which corresponds to the specified typeInfo (assuming an ejb name).static ObjectgetPrimitiveType(Object type)Returns the type info for a primitive type.ObjectgetSumReturnType(Object type)Return JDO QL return type for Sum function for a given type.ObjectgetTypeInfo(Class clazz)The method returns a type info by type name by class object.ObjectgetTypeInfo(String name)The method returns a type info by type name.ObjectgetTypeInfoForAbstractSchema(String abstractSchema)Returns the typeInfo (the ejb name) for the specified abstract schema.static StringgetTypeName(Object type)Returns the type name for a specified type info.static ObjectgetWrapperType(Object type)Returns the type info for a wrapper class type.booleanhasLocalInterface(Object typeInfo)Returnstrueif the bean with the specified ejb name has a local interface.booleanhasRemoteInterface(Object typeInfo)Returnstrueif the bean with the specified ejb name has a remote interface.static booleanisBooleanType(Object type)Returnstrueif type is boolean or java.lang.Booleanstatic booleanisCharType(Object type)Returnstrueif type is char or java.lang.CharacterbooleanisCollectionType(Object type)Returnstrueif type is a collection type.booleanisCompatibleWith(Object left, Object right)Implements type compatibility.booleanisDateTimeType(Object type)Returnstrueif type is a date or time typestatic booleanisDoubleType(Object type)Returnstrueif type is double or java.lang.Double.booleanisEjbName(Object typeInfo)Returnstrueif the specified type info denotes an ejb name.booleanisEjbOrInterfaceName(Object typeInfo)Returnstrueif the specified type info denotes an ejb name or the name of a local interface or the name of a remote interface.static booleanisErrorType(Object type)Returnstrueif type denotes the error type.static booleanisFloatingPointType(Object type)Returnstrueif type is a floating point type or wrapper class of a floating point type.static booleanisIntType(Object type)Returnstrueif type is int or java.lang.IntegerbooleanisLocalInterface(Object typeInfo)Returnstrueif the specified type info denotes a local interface.booleanisLocalInterfaceOfEjb(Object typeInfo, String ejbName)Returnstrueif the specified type info denotes the local interface of the bean with the specified ejb name.static booleanisNumberType(Object type)Returnstrueif type is a NumerType, which means it is either a numeric primitive or a numeric wrapper class.static booleanisNumericType(Object type)Returnstrueif type is a primitive numeric type such as byte, int etc.static booleanisNumericWrapperType(Object type)Returnstrueif type is a wrapper class of a primitive numeric type such as java.lang.Byte, java.lang.Integer etc.booleanisOrderableType(Object type)Returnstrueif type is an orderable typebooleanisRelationship(Object fieldInfo)Returnstrueif the specified field info denotes a relationship field.booleanisRemoteInterface(Object typeInfo)Returnstrueif the specified type info denotes a remote interface.booleanisRemoteInterfaceOfEjb(Object typeInfo, String ejbName)Returnstrueif the specified type info denotes the remote interface of the bean with the specified ejb name.static booleanisStringType(Object type)Returnstrueif type denotes java.lang.String.static ObjectunaryNumericPromotion(Object type)Implements unray numeric promotion as defined in the Java Language Specification section 5.6.1
-
-
-
Field Detail
-
errorType
public static final Object errorType
Represents the internal error type.
-
booleanType
public static final Object booleanType
Represents the primitive type boolean.
-
byteType
public static final Object byteType
Represents the primitive type byte.
-
shortType
public static final Object shortType
Represents the primitive type short.
-
charType
public static final Object charType
Represents the primitive type char.
-
intType
public static final Object intType
Represents the primitive type int.
-
longType
public static final Object longType
Represents the primitive type long.
-
floatType
public static final Object floatType
Represents the primitive type float.
-
doubleType
public static final Object doubleType
Represents the primitive type double.
-
booleanClassType
public static final Object booleanClassType
Represents the wrapper class type boolean.
-
byteClassType
public static final Object byteClassType
Represents the wrapper class type byte.
-
shortClassType
public static final Object shortClassType
Represents the wrapper class type short.
-
characterClassType
public static final Object characterClassType
Represents the wrapper class type char.
-
integerClassType
public static final Object integerClassType
Represents the wrapper class type int.
-
longClassType
public static final Object longClassType
Represents the wrapper class type long.
-
floatClassType
public static final Object floatClassType
Represents the wrapper class type float.
-
doubleClassType
public static final Object doubleClassType
Represents the wrapper class type double.
-
stringType
public static final Object stringType
Represents the type java.lang.String.
-
bigDecimalType
public static final Object bigDecimalType
Represents the type java.math.BigDecimal.
-
bigIntegerType
public static final Object bigIntegerType
Represents the type java.math.BigInteger.
-
numericTypes
protected static final Set numericTypes
Set of names of numeric types.
-
numericWrapperTypes
protected static final Set numericWrapperTypes
Set of names of numeric wrapper classes.
-
dateTimeTypes
protected static final Set dateTimeTypes
Set of names of date and time types.
-
model
protected Model model
Meta data access.
-
nameMapper
protected NameMapper nameMapper
Name mapping EJB <-> JDO.
-
msgs
protected static final ResourceBundle msgs
I18N support.
-
-
Constructor Detail
-
TypeSupport
public TypeSupport(Model model, NameMapper nameMapper)
Creates a new TypeSupport using the specified model instance to access meta data and the specified nameMapper for EJB <-> JDO name mapping.
-
-
Method Detail
-
getTypeInfo
public Object getTypeInfo(String name)
The method returns a type info by type name. If the type name denotes a class the name should be fully qualified. The method uses the type name as type info.
-
getTypeInfo
public Object getTypeInfo(Class clazz)
The method returns a type info by type name by class object.
-
isErrorType
public static boolean isErrorType(Object type)
Returnstrueif type denotes the error type.
-
isBooleanType
public static boolean isBooleanType(Object type)
Returnstrueif type is boolean or java.lang.Boolean
-
isCharType
public static boolean isCharType(Object type)
Returnstrueif type is char or java.lang.Character
-
isIntType
public static boolean isIntType(Object type)
Returnstrueif type is int or java.lang.Integer
-
isDoubleType
public static boolean isDoubleType(Object type)
Returnstrueif type is double or java.lang.Double.
-
isNumericType
public static boolean isNumericType(Object type)
Returnstrueif type is a primitive numeric type such as byte, int etc.
-
isNumericWrapperType
public static boolean isNumericWrapperType(Object type)
Returnstrueif type is a wrapper class of a primitive numeric type such as java.lang.Byte, java.lang.Integer etc.
-
isNumberType
public static boolean isNumberType(Object type)
Returnstrueif type is a NumerType, which means it is either a numeric primitive or a numeric wrapper class.
-
isFloatingPointType
public static boolean isFloatingPointType(Object type)
Returnstrueif type is a floating point type or wrapper class of a floating point type.
-
isStringType
public static boolean isStringType(Object type)
Returnstrueif type denotes java.lang.String.
-
isCollectionType
public boolean isCollectionType(Object type)
Returnstrueif type is a collection type.
-
isDateTimeType
public boolean isDateTimeType(Object type)
Returnstrueif type is a date or time type
-
isOrderableType
public boolean isOrderableType(Object type)
Returnstrueif type is an orderable type
-
getPrimitiveType
public static Object getPrimitiveType(Object type)
Returns the type info for a primitive type. The method returnserrorTypeif the specified type is not a primitive type.
-
getWrapperType
public static Object getWrapperType(Object type)
Returns the type info for a wrapper class type. The method returnserrorTypeif the specified type is not a wrapper class type.
-
binaryNumericPromotion
public static Object binaryNumericPromotion(Object left, Object right)
Implements binary numeric promotion as defined in the Java Language Specification section 5.6.2
-
unaryNumericPromotion
public static Object unaryNumericPromotion(Object type)
Implements unray numeric promotion as defined in the Java Language Specification section 5.6.1
-
isCompatibleWith
public boolean isCompatibleWith(Object left, Object right)
Implements type compatibility. The method returnstrueif left is compatible with right. This is equivalent to rightClass.isAssignableFrom(leftClass). Note, the method does not support inheritance.
-
getTypeName
public static String getTypeName(Object type)
Returns the type name for a specified type info.
-
getTypeInfoForAbstractSchema
public Object getTypeInfoForAbstractSchema(String abstractSchema)
Returns the typeInfo (the ejb name) for the specified abstract schema.
-
getAbstractSchemaForTypeInfo
public String getAbstractSchemaForTypeInfo(Object typeInfo)
Returns the typeInfo (the ejb name) for the specified abstract schema.
-
getFieldType
public Object getFieldType(Object typeInfo, String fieldName)
Returns the type info for the type of the given field.
-
getFieldInfo
public Object getFieldInfo(Object typeInfo, String fieldName)
Returns the field info for the specified field of the specified type. The field info is opaque for the caller. MethodsisRelationship(java.lang.Object)andgetElementType(java.lang.Object)allow to get details for a given field info.
-
isRelationship
public boolean isRelationship(Object fieldInfo)
Returnstrueif the specified field info denotes a relationship field.
-
getElementType
public Object getElementType(Object fieldInfo)
Returns the type info of the element type if the specified field info denotes a collection relationship. Otherwise it returnsnull.
-
getPCForTypeInfo
public String getPCForTypeInfo(Object typeInfo)
Gets the name of the persistence-capable class which corresponds to the specified typeInfo (assuming an ejb name). The method returs the type name of the specified typeInfo, it the typeInfo does not denote an ejb-name (e.g. a local or remote interface).
-
isEjbName
public boolean isEjbName(Object typeInfo)
Returnstrueif the specified type info denotes an ejb name.
-
isEjbOrInterfaceName
public boolean isEjbOrInterfaceName(Object typeInfo)
Returnstrueif the specified type info denotes an ejb name or the name of a local interface or the name of a remote interface.
-
isRemoteInterfaceOfEjb
public boolean isRemoteInterfaceOfEjb(Object typeInfo, String ejbName)
Returnstrueif the specified type info denotes the remote interface of the bean with the specified ejb name.
-
isLocalInterfaceOfEjb
public boolean isLocalInterfaceOfEjb(Object typeInfo, String ejbName)
Returnstrueif the specified type info denotes the local interface of the bean with the specified ejb name.
-
isRemoteInterface
public boolean isRemoteInterface(Object typeInfo)
Returnstrueif the specified type info denotes a remote interface.
-
isLocalInterface
public boolean isLocalInterface(Object typeInfo)
Returnstrueif the specified type info denotes a local interface.
-
hasRemoteInterface
public boolean hasRemoteInterface(Object typeInfo)
Returnstrueif the bean with the specified ejb name has a remote interface.
-
hasLocalInterface
public boolean hasLocalInterface(Object typeInfo)
Returnstrueif the bean with the specified ejb name has a local interface.
-
getSumReturnType
public Object getSumReturnType(Object type)
Return JDO QL return type for Sum function for a given type.- Parameters:
type- is a number data type
-
getAvgReturnType
public Object getAvgReturnType(Object type)
Return JDO QL return type for Avg function for a given type.- Parameters:
type- is a number data type
-
-