com.sun.jdo.spi.persistence.support.ejb.ejbqlc
Class TypeSupport

java.lang.Object
  extended by com.sun.jdo.spi.persistence.support.ejb.ejbqlc.TypeSupport

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

Field Detail

errorType

public static final java.lang.Object errorType
Represents the internal error type.


booleanType

public static final java.lang.Object booleanType
Represents the primitive type boolean.


byteType

public static final java.lang.Object byteType
Represents the primitive type byte.


shortType

public static final java.lang.Object shortType
Represents the primitive type short.


charType

public static final java.lang.Object charType
Represents the primitive type char.


intType

public static final java.lang.Object intType
Represents the primitive type int.


longType

public static final java.lang.Object longType
Represents the primitive type long.


floatType

public static final java.lang.Object floatType
Represents the primitive type float.


doubleType

public static final java.lang.Object doubleType
Represents the primitive type double.


booleanClassType

public static final java.lang.Object booleanClassType
Represents the wrapper class type boolean.


byteClassType

public static final java.lang.Object byteClassType
Represents the wrapper class type byte.


shortClassType

public static final java.lang.Object shortClassType
Represents the wrapper class type short.


characterClassType

public static final java.lang.Object characterClassType
Represents the wrapper class type char.


integerClassType

public static final java.lang.Object integerClassType
Represents the wrapper class type int.


longClassType

public static final java.lang.Object longClassType
Represents the wrapper class type long.


floatClassType

public static final java.lang.Object floatClassType
Represents the wrapper class type float.


doubleClassType

public static final java.lang.Object doubleClassType
Represents the wrapper class type double.


stringType

public static final java.lang.Object stringType
Represents the type java.lang.String.


bigDecimalType

public static final java.lang.Object bigDecimalType
Represents the type java.math.BigDecimal.


bigIntegerType

public static final java.lang.Object bigIntegerType
Represents the type java.math.BigInteger.


numericTypes

protected static final java.util.Set numericTypes
Set of names of numeric types.


numericWrapperTypes

protected static final java.util.Set numericWrapperTypes
Set of names of numeric wrapper classes.


dateTimeTypes

protected static final java.util.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 java.util.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 java.lang.Object getTypeInfo(java.lang.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 java.lang.Object getTypeInfo(java.lang.Class clazz)
The method returns a type info by type name by class object.


isErrorType

public static boolean isErrorType(java.lang.Object type)
Returns true if type denotes the error type.


isBooleanType

public static boolean isBooleanType(java.lang.Object type)
Returns true if type is boolean or java.lang.Boolean


isCharType

public static boolean isCharType(java.lang.Object type)
Returns true if type is char or java.lang.Character


isIntType

public static boolean isIntType(java.lang.Object type)
Returns true if type is int or java.lang.Integer


isDoubleType

public static boolean isDoubleType(java.lang.Object type)
Returns true if type is double or java.lang.Double.


isNumericType

public static boolean isNumericType(java.lang.Object type)
Returns true if type is a primitive numeric type such as byte, int etc.


isNumericWrapperType

public static boolean isNumericWrapperType(java.lang.Object type)
Returns true 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(java.lang.Object type)
Returns true if type is a NumerType, which means it is either a numeric primitive or a numeric wrapper class.


isFloatingPointType

public static boolean isFloatingPointType(java.lang.Object type)
Returns true if type is a floating point type or wrapper class of a floating point type.


isStringType

public static boolean isStringType(java.lang.Object type)
Returns true if type denotes java.lang.String.


isCollectionType

public boolean isCollectionType(java.lang.Object type)
Returns true if type is a collection type.


isDateTimeType

public boolean isDateTimeType(java.lang.Object type)
Returns true if type is a date or time type


isOrderableType

public boolean isOrderableType(java.lang.Object type)
Returns true if type is an orderable type


getPrimitiveType

public static java.lang.Object getPrimitiveType(java.lang.Object type)
Returns the type info for a primitive type. The method returns errorType if the specified type is not a primitive type.


getWrapperType

public static java.lang.Object getWrapperType(java.lang.Object type)
Returns the type info for a wrapper class type. The method returns errorType if the specified type is not a wrapper class type.


binaryNumericPromotion

public static java.lang.Object binaryNumericPromotion(java.lang.Object left,
                                                      java.lang.Object right)
Implements binary numeric promotion as defined in the Java Language Specification section 5.6.2


unaryNumericPromotion

public static java.lang.Object unaryNumericPromotion(java.lang.Object type)
Implements unray numeric promotion as defined in the Java Language Specification section 5.6.1


isCompatibleWith

public boolean isCompatibleWith(java.lang.Object left,
                                java.lang.Object right)
Implements type compatibility. The method returns true if left is compatible with right. This is equivalent to rightClass.isAssignableFrom(leftClass). Note, the method does not support inheritance.


getTypeName

public static java.lang.String getTypeName(java.lang.Object type)
Returns the type name for a specified type info.


getTypeInfoForAbstractSchema

public java.lang.Object getTypeInfoForAbstractSchema(java.lang.String abstractSchema)
Returns the typeInfo (the ejb name) for the specified abstract schema.


getAbstractSchemaForTypeInfo

public java.lang.String getAbstractSchemaForTypeInfo(java.lang.Object typeInfo)
Returns the typeInfo (the ejb name) for the specified abstract schema.


getFieldType

public java.lang.Object getFieldType(java.lang.Object typeInfo,
                                     java.lang.String fieldName)
Returns the type info for the type of the given field.


getFieldInfo

public java.lang.Object getFieldInfo(java.lang.Object typeInfo,
                                     java.lang.String fieldName)
Returns the field info for the specified field of the specified type. The field info is opaque for the caller. Methods isRelationship(java.lang.Object) and getElementType(java.lang.Object) allow to get details for a given field info.


isRelationship

public boolean isRelationship(java.lang.Object fieldInfo)
Returns true if the specified field info denotes a relationship field.


getElementType

public java.lang.Object getElementType(java.lang.Object fieldInfo)
Returns the type info of the element type if the specified field info denotes a collection relationship. Otherwise it returns null.


getPCForTypeInfo

public java.lang.String getPCForTypeInfo(java.lang.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(java.lang.Object typeInfo)
Returns true if the specified type info denotes an ejb name.


isEjbOrInterfaceName

public boolean isEjbOrInterfaceName(java.lang.Object typeInfo)
Returns true 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(java.lang.Object typeInfo,
                                      java.lang.String ejbName)
Returns true if the specified type info denotes the remote interface of the bean with the specified ejb name.


isLocalInterfaceOfEjb

public boolean isLocalInterfaceOfEjb(java.lang.Object typeInfo,
                                     java.lang.String ejbName)
Returns true if the specified type info denotes the local interface of the bean with the specified ejb name.


isRemoteInterface

public boolean isRemoteInterface(java.lang.Object typeInfo)
Returns true if the specified type info denotes a remote interface.


isLocalInterface

public boolean isLocalInterface(java.lang.Object typeInfo)
Returns true if the specified type info denotes a local interface.


hasRemoteInterface

public boolean hasRemoteInterface(java.lang.Object typeInfo)
Returns true if the bean with the specified ejb name has a remote interface.


hasLocalInterface

public boolean hasLocalInterface(java.lang.Object typeInfo)
Returns true if the bean with the specified ejb name has a local interface.


getSumReturnType

public java.lang.Object getSumReturnType(java.lang.Object type)
Return JDO QL return type for Sum function for a given type.

Parameters:
type - is a number data type

getAvgReturnType

public java.lang.Object getAvgReturnType(java.lang.Object type)
Return JDO QL return type for Avg function for a given type.

Parameters:
type - is a number data type

getMinMaxReturnType

public java.lang.Object getMinMaxReturnType(java.lang.Object type)
Return JDO QL return type for Min/Max function for a given type.

Parameters:
type - is an orderable data type


Copyright © 2012 GlassFish Community. All Rights Reserved.