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 Details

    • 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 com.sun.jdo.api.persistence.model.Model model
      Meta data access.
    • nameMapper

      protected NameMapper nameMapper
      Name mapping EJB <-> JDO.
    • msgs

      protected static final ResourceBundle msgs
      I18N support.
  • Constructor Details

    • TypeSupport

      public TypeSupport(com.sun.jdo.api.persistence.model.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 Details

    • 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)
      Returns true if type denotes the error type.
    • isBooleanType

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

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

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

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

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

      public static boolean isNumericWrapperType(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(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(Object type)
      Returns true if type is a floating point type or wrapper class of a floating point type.
    • isStringType

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

      public boolean isCollectionType(Object type)
      Returns true if type is a collection type.
    • isDateTimeType

      public boolean isDateTimeType(Object type)
      Returns true if type is a date or time type
    • isOrderableType

      public boolean isOrderableType(Object type)
      Returns true if type is an orderable type
    • getPrimitiveType

      public static Object getPrimitiveType(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 Object getWrapperType(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 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 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 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. Methods isRelationship(java.lang.Object) and getElementType(java.lang.Object) allow to get details for a given field info.
    • isRelationship

      public boolean isRelationship(Object fieldInfo)
      Returns true 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 returns null.
    • 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)
      Returns true if the specified type info denotes an ejb name.
    • isEjbOrInterfaceName

      public boolean isEjbOrInterfaceName(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(Object typeInfo, 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(Object typeInfo, 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(Object typeInfo)
      Returns true if the specified type info denotes a remote interface.
    • isLocalInterface

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

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

      public boolean hasLocalInterface(Object typeInfo)
      Returns true 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
    • getMinMaxReturnType

      public Object getMinMaxReturnType(Object type)
      Return JDO QL return type for Min/Max function for a given type.
      Parameters:
      type - is an orderable data type