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 Object
bigDecimalType
Represents the type java.math.BigDecimal.static Object
bigIntegerType
Represents the type java.math.BigInteger.static Object
booleanClassType
Represents the wrapper class type boolean.static Object
booleanType
Represents the primitive type boolean.static Object
byteClassType
Represents the wrapper class type byte.static Object
byteType
Represents the primitive type byte.static Object
characterClassType
Represents the wrapper class type char.static Object
charType
Represents the primitive type char.protected static Set
dateTimeTypes
Set of names of date and time types.static Object
doubleClassType
Represents the wrapper class type double.static Object
doubleType
Represents the primitive type double.static Object
errorType
Represents the internal error type.static Object
floatClassType
Represents the wrapper class type float.static Object
floatType
Represents the primitive type float.static Object
integerClassType
Represents the wrapper class type int.static Object
intType
Represents the primitive type int.static Object
longClassType
Represents the wrapper class type long.static Object
longType
Represents the primitive type long.protected Model
model
Meta data access.protected static ResourceBundle
msgs
I18N support.protected NameMapper
nameMapper
Name mapping EJB <-> JDO.protected static Set
numericTypes
Set of names of numeric types.protected static Set
numericWrapperTypes
Set of names of numeric wrapper classes.static Object
shortClassType
Represents the wrapper class type short.static Object
shortType
Represents the primitive type short.static Object
stringType
Represents 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 Object
binaryNumericPromotion(Object left, Object right)
Implements binary numeric promotion as defined in the Java Language Specification section 5.6.2String
getAbstractSchemaForTypeInfo(Object typeInfo)
Returns the typeInfo (the ejb name) for the specified abstract schema.Object
getAvgReturnType(Object type)
Return JDO QL return type for Avg function for a given type.Object
getElementType(Object fieldInfo)
Returns the type info of the element type if the specified field info denotes a collection relationship.Object
getFieldInfo(Object typeInfo, String fieldName)
Returns the field info for the specified field of the specified type.Object
getFieldType(Object typeInfo, String fieldName)
Returns the type info for the type of the given field.Object
getMinMaxReturnType(Object type)
Return JDO QL return type for Min/Max function for a given type.String
getPCForTypeInfo(Object typeInfo)
Gets the name of the persistence-capable class which corresponds to the specified typeInfo (assuming an ejb name).static Object
getPrimitiveType(Object type)
Returns the type info for a primitive type.Object
getSumReturnType(Object type)
Return JDO QL return type for Sum function for a given type.Object
getTypeInfo(Class clazz)
The method returns a type info by type name by class object.Object
getTypeInfo(String name)
The method returns a type info by type name.Object
getTypeInfoForAbstractSchema(String abstractSchema)
Returns the typeInfo (the ejb name) for the specified abstract schema.static String
getTypeName(Object type)
Returns the type name for a specified type info.static Object
getWrapperType(Object type)
Returns the type info for a wrapper class type.boolean
hasLocalInterface(Object typeInfo)
Returnstrue
if the bean with the specified ejb name has a local interface.boolean
hasRemoteInterface(Object typeInfo)
Returnstrue
if the bean with the specified ejb name has a remote interface.static boolean
isBooleanType(Object type)
Returnstrue
if type is boolean or java.lang.Booleanstatic boolean
isCharType(Object type)
Returnstrue
if type is char or java.lang.Characterboolean
isCollectionType(Object type)
Returnstrue
if type is a collection type.boolean
isCompatibleWith(Object left, Object right)
Implements type compatibility.boolean
isDateTimeType(Object type)
Returnstrue
if type is a date or time typestatic boolean
isDoubleType(Object type)
Returnstrue
if type is double or java.lang.Double.boolean
isEjbName(Object typeInfo)
Returnstrue
if the specified type info denotes an ejb name.boolean
isEjbOrInterfaceName(Object typeInfo)
Returnstrue
if the specified type info denotes an ejb name or the name of a local interface or the name of a remote interface.static boolean
isErrorType(Object type)
Returnstrue
if type denotes the error type.static boolean
isFloatingPointType(Object type)
Returnstrue
if type is a floating point type or wrapper class of a floating point type.static boolean
isIntType(Object type)
Returnstrue
if type is int or java.lang.Integerboolean
isLocalInterface(Object typeInfo)
Returnstrue
if the specified type info denotes a local interface.boolean
isLocalInterfaceOfEjb(Object typeInfo, String ejbName)
Returnstrue
if the specified type info denotes the local interface of the bean with the specified ejb name.static boolean
isNumberType(Object type)
Returnstrue
if type is a NumerType, which means it is either a numeric primitive or a numeric wrapper class.static boolean
isNumericType(Object type)
Returnstrue
if type is a primitive numeric type such as byte, int etc.static boolean
isNumericWrapperType(Object type)
Returnstrue
if type is a wrapper class of a primitive numeric type such as java.lang.Byte, java.lang.Integer etc.boolean
isOrderableType(Object type)
Returnstrue
if type is an orderable typeboolean
isRelationship(Object fieldInfo)
Returnstrue
if the specified field info denotes a relationship field.boolean
isRemoteInterface(Object typeInfo)
Returnstrue
if the specified type info denotes a remote interface.boolean
isRemoteInterfaceOfEjb(Object typeInfo, String ejbName)
Returnstrue
if the specified type info denotes the remote interface of the bean with the specified ejb name.static boolean
isStringType(Object type)
Returnstrue
if type denotes java.lang.String.static Object
unaryNumericPromotion(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)
Returnstrue
if type denotes the error type.
-
isBooleanType
public static boolean isBooleanType(Object type)
Returnstrue
if type is boolean or java.lang.Boolean
-
isCharType
public static boolean isCharType(Object type)
Returnstrue
if type is char or java.lang.Character
-
isIntType
public static boolean isIntType(Object type)
Returnstrue
if type is int or java.lang.Integer
-
isDoubleType
public static boolean isDoubleType(Object type)
Returnstrue
if type is double or java.lang.Double.
-
isNumericType
public static boolean isNumericType(Object type)
Returnstrue
if type is a primitive numeric type such as byte, int etc.
-
isNumericWrapperType
public static boolean isNumericWrapperType(Object type)
Returnstrue
if 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)
Returnstrue
if type is a NumerType, which means it is either a numeric primitive or a numeric wrapper class.
-
isFloatingPointType
public static boolean isFloatingPointType(Object type)
Returnstrue
if type is a floating point type or wrapper class of a floating point type.
-
isStringType
public static boolean isStringType(Object type)
Returnstrue
if type denotes java.lang.String.
-
isCollectionType
public boolean isCollectionType(Object type)
Returnstrue
if type is a collection type.
-
isDateTimeType
public boolean isDateTimeType(Object type)
Returnstrue
if type is a date or time type
-
isOrderableType
public boolean isOrderableType(Object type)
Returnstrue
if type is an orderable type
-
getPrimitiveType
public static Object getPrimitiveType(Object type)
Returns the type info for a primitive type. The method returnserrorType
if 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 returnserrorType
if 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 returnstrue
if 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)
Returnstrue
if 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)
Returnstrue
if the specified type info denotes an ejb name.
-
isEjbOrInterfaceName
public boolean isEjbOrInterfaceName(Object typeInfo)
Returnstrue
if 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)
Returnstrue
if the specified type info denotes the remote interface of the bean with the specified ejb name.
-
isLocalInterfaceOfEjb
public boolean isLocalInterfaceOfEjb(Object typeInfo, String ejbName)
Returnstrue
if the specified type info denotes the local interface of the bean with the specified ejb name.
-
isRemoteInterface
public boolean isRemoteInterface(Object typeInfo)
Returnstrue
if the specified type info denotes a remote interface.
-
isLocalInterface
public boolean isLocalInterface(Object typeInfo)
Returnstrue
if the specified type info denotes a local interface.
-
hasRemoteInterface
public boolean hasRemoteInterface(Object typeInfo)
Returnstrue
if the bean with the specified ejb name has a remote interface.
-
hasLocalInterface
public boolean hasLocalInterface(Object typeInfo)
Returnstrue
if 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
-
-