Class TypeTable


  • public class TypeTable
    extends Object
    Version:
    0.1
    Author:
    Michael Bouschen, Shing Wai Chan
    • Field Detail

      • nullType

        public static final NullType nullType
        Represents the type of null
      • errorType

        public static final ErrorType errorType
        Represents the internal error type.
      • booleanType

        public BooleanType booleanType
        Represents the type boolean.
      • charType

        public IntegralType charType
        Represents the type char.
      • byteType

        public IntegralType byteType
        Represents the type byte.
      • shortType

        public IntegralType shortType
        Represents the type short.
      • intType

        public IntegralType intType
        Represents the type int.
      • longType

        public IntegralType longType
        Represents the type long.
      • stringType

        public StringType stringType
        Represents the type java.lang.String.
      • bigDecimalType

        public MathType bigDecimalType
        Represents the type java.math.BigDecimal
      • bigIntegerType

        public MathType bigIntegerType
        Represents the type java.math.BigInteger
      • model

        protected Model model
        The model used to access class meta info
      • classLoader

        protected ClassLoader classLoader
        Store class loader for Class.forName lookup
      • types

        protected Map types
        The list of actual known types.
    • Method Detail

      • removeInstance

        public static void removeInstance​(ClassLoader classLoader)
      • checkType

        public Type checkType​(String name)
        Checks for the type with the specified name. First the internal type table is checked. If the type is not found it checks Class.forName. If the type is found the internal type table is updated (optimization for further access). If the type is neither in the type table nor found by forName null is returned and the type table is not changed. Otherwise the Type representation of the type is returned.
        Parameters:
        name - the name of the type to be checked.
        Returns:
        the Type object representing the type with the specified name or null when the type was not found.
      • checkType

        public Type checkType​(Class clazz)
        Checks for the type with the specified name. First the internal type table is checked. If the type is not found it checks Class.forName. If the type is found the internal type table is updated (optimization for further access). If the type is neither in the type table nor found by forName null is returned and the type table is not changed. Otherwise the Type representation of the type is returned.
        Parameters:
        clazz - the name of the type to be checked.
        Returns:
        the Type object representing the type with the specified name or null when the type was not found.
      • binaryNumericPromotion

        public Type binaryNumericPromotion​(Type left,
                                           Type right)
        Implements binary numeric promotion as defined in the Java Language Specification section 5.6.2
      • unaryNumericPromotion

        public Type unaryNumericPromotion​(Type type)
        Implements unray numeric promotion as defined in the Java Language Specification section 5.6.1
      • isNumberType

        public boolean isNumberType​(Type type)
        Returns true if type is a NumericType or compatible to java.lang.Number
      • isIntegralType

        public boolean isIntegralType​(Type type)
        Returns true if type is an integral type or a Java wrapper class type wrapping an integral type.
      • isFloatingPointType

        public boolean isFloatingPointType​(Type type)
        Returns true if type is a floating point type or a Java wrapper class type wrapping a floating point integral type.
      • isDoubleType

        public boolean isDoubleType​(Type type)
        Returns true if type is double or java.lang.Double
      • isIntType

        public boolean isIntType​(Type type)
        Returns true if type is int or java.lang.Integer
      • isCharType

        public boolean isCharType​(Type type)
        Returns true if type is char or java.lang.Character
      • isBooleanType

        public boolean isBooleanType​(Type type)
        Returns true if type is boolean or java.lang.Boolean
      • isPersistenceCapableType

        public boolean isPersistenceCapableType​(Type type)
        Returns true if type denotes a pertsistence capable class Note, it returns false for non ClassType values, especially for NullType and ErrorType.
      • isCollectionType

        public boolean isCollectionType​(Type type)
        Returns true if type denotes a collection type. Note, it returns false for non ClassType values, especially for NullType and ErrorType.
      • isJavaLangMathType

        public boolean isJavaLangMathType​(Type type)
        Returns true if type denotes a collection type. Note, it returns false for non ClassType values, especially for NullType and ErrorType.
      • getSumReturnType

        public Type getSumReturnType​(Type type)
        Return JDO QL return type for Sum function for a given type.
        Parameters:
        type - is a number data type
      • getAvgReturnType

        public Type getAvgReturnType​(Type type)
        Return JDO QL return type for Avg function for a given type.
        Parameters:
        type - is a number data type
      • getMinMaxReturnType

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