Documentation of 'org.hsqldb.types.NumberType' Java class
NumberType
org.hsqldb.types

Class NumberType

  • All Implemented Interfaces:
    java.lang.Cloneable, SchemaObject


    public final class NumberType
    extends Type
    Type subclass for all NUMBER types.

    Since:
    1.9.0
    • Field Detail

      • defaultNumericPrecision

        public static final int defaultNumericPrecision
        See Also:
        Constant Field Values
      • SQL_NUMERIC_DEFAULT_INT

        public static final Type SQL_NUMERIC_DEFAULT_INT
      • MAX_DOUBLE

        public static final java.math.BigDecimal MAX_DOUBLE
      • MAX_LONG

        public static final java.math.BigDecimal MAX_LONG
      • MIN_LONG

        public static final java.math.BigDecimal MIN_LONG
      • MAX_INT

        public static final java.math.BigDecimal MAX_INT
      • MIN_INT

        public static final java.math.BigDecimal MIN_INT
      • MIN_LONG_BI

        public static final java.math.BigInteger MIN_LONG_BI
      • MAX_LONG_BI

        public static final java.math.BigInteger MAX_LONG_BI
    • Constructor Detail

      • NumberType

        public NumberType(int type,
                          long precision,
                          int scale)
    • Method Detail

      • getPrecision

        public int getPrecision()
        Returns decimal precision for NUMERIC/DECIMAL. Returns binary precision for other parts.
      • getDecimalPrecision

        public int getDecimalPrecision()
        Returns decimal precision.
      • displaySize

        public int displaySize()
        Specified by:
        displaySize in class Type
      • getJDBCTypeCode

        public int getJDBCTypeCode()
        Description copied from class: Type
        Returns the JDBC type number of type, if it exists, otherwise the HSQLDB / SQL type.
        Specified by:
        getJDBCTypeCode in class Type
      • getJDBCClass

        public java.lang.Class getJDBCClass()
        Specified by:
        getJDBCClass in class Type
      • getJDBCClassName

        public java.lang.String getJDBCClassName()
        Description copied from class: Type
        Returns the JDBC class name of type, if it exists, otherwise the HSQLDB class name.
        Specified by:
        getJDBCClassName in class Type
      • getNameString

        public java.lang.String getNameString()
        Description copied from class: Type
        Returns the name of the type
        Specified by:
        getNameString in class Type
      • getFullNameString

        public java.lang.String getFullNameString()
        Description copied from class: Type
        Returns the name of the type
        Overrides:
        getFullNameString in class Type
      • getDefinition

        public java.lang.String getDefinition()
        Description copied from class: Type
        Returns the full definition of the type, including parameters
        Specified by:
        getDefinition in class Type
      • getMaxScale

        public int getMaxScale()
        Overrides:
        getMaxScale in class Type
      • acceptsScale

        public boolean acceptsScale()
        Overrides:
        acceptsScale in class Type
      • isNumberType

        public boolean isNumberType()
        Overrides:
        isNumberType in class Type
      • isIntegralType

        public boolean isIntegralType()
        Overrides:
        isIntegralType in class Type
      • isDecimalType

        public boolean isDecimalType()
        Overrides:
        isDecimalType in class Type
      • getNominalWidth

        public int getNominalWidth()
      • getAggregateType

        public Type getAggregateType(Type other)
        Description copied from class: Type
        Common type used in comparison opertions. other must be comparable with this.
        Specified by:
        getAggregateType in class Type
      • getCombinedType

        public Type getCombinedType(Session session,
                                    Type other,
                                    int operation)
        Returns a SQL type "wide" enough to represent the result of the expression.
        A type is "wider" than the other if it can represent all its numeric values.
        Arithmetic operation terms are promoted to a type that can represent the resulting values and avoid incorrect results.

        FLOAT/REAL/DOUBLE used in an operation results in the same type, regardless of the type of the other operand. When the result or the expression is converted to the type of the target column for storage, an exception is thrown if the resulting value cannot be stored in the column

        Types narrower than INTEGER (int) are promoted to INTEGER. The order of promotion is as follows

        INTEGER, BIGINT, NUMERIC/DECIMAL

        TINYINT and SMALLINT in any combination return INTEGER
        TINYINT/SMALLINT/INTEGER and INTEGER return BIGINT
        TINYINT/SMALLINT/INTEGER and BIGINT return NUMERIC/DECIMAL
        BIGINT and BIGINT return NUMERIC/DECIMAL
        REAL/FLOAT/DOUBLE and any type return REAL/FLOAT/DOUBLE
        NUMERIC/DECIMAL any type other than REAL/FLOAT/DOUBLE returns NUMERIC/DECIMAL
        In the case of NUMERIC/DECIMAL returned, the result precision is always large enough to express any value result, while the scale depends on the operation:
        For ADD/SUBTRACT/DIVIDE, the scale is the larger of the two
        For MULTIPLY, the scale is the sum of the two scales

        Specified by:
        getCombinedType in class Type
      • compare

        public int compare(Session session,
                           java.lang.Object a,
                           java.lang.Object b)
        Specified by:
        compare in class Type
      • convertToType

        public java.lang.Object convertToType(SessionInterface session,
                                              java.lang.Object a,
                                              Type otherType)
        Description copied from class: Type
        Same as castToType except for CHARACTER values. Perform string truncation of trailing spaces only. For other long strings, it raises an exception.
        Specified by:
        convertToType in class Type
      • convertToTypeJDBC

        public java.lang.Object convertToTypeJDBC(SessionInterface session,
                                                  java.lang.Object a,
                                                  Type otherType)
        Description copied from class: Type
        Convert type for JDBC reads. Same as convertToType, but supports non-standard SQL conversions supported by JDBC
        Overrides:
        convertToTypeJDBC in class Type
      • convertToDefaultType

        public java.lang.Object convertToDefaultType(SessionInterface session,
                                                     java.lang.Object a)
        Relaxes SQL parameter type enforcement for DECIMAL, allowing long values.
        Specified by:
        convertToDefaultType in class Type
      • toDouble

        public static double toDouble(java.lang.Object a)
      • convertToString

        public java.lang.String convertToString(java.lang.Object a)
        Specified by:
        convertToString in class Type
      • convertToSQLString

        public java.lang.String convertToSQLString(java.lang.Object a)
        Specified by:
        convertToSQLString in class Type
      • canConvertFrom

        public boolean canConvertFrom(Type otherType)
        Specified by:
        canConvertFrom in class Type
      • canMoveFrom

        public int canMoveFrom(Type otherType)
        Description copied from class: Type
        Can convert without changing the object
        Overrides:
        canMoveFrom in class Type
        Returns:
        0 always, 1 range check required, -1 never
      • compareToTypeRange

        public int compareToTypeRange(java.lang.Object o)
        Overrides:
        compareToTypeRange in class Type
      • add

        public java.lang.Object add(Session session,
                                    java.lang.Object a,
                                    java.lang.Object b,
                                    Type otherType)
        Overrides:
        add in class Type
      • subtract

        public java.lang.Object subtract(Session session,
                                         java.lang.Object a,
                                         java.lang.Object b,
                                         Type otherType)
        Overrides:
        subtract in class Type
      • multiply

        public java.lang.Object multiply(java.lang.Object a,
                                         java.lang.Object b)
        Overrides:
        multiply in class Type
      • divide

        public java.lang.Object divide(Session session,
                                       java.lang.Object a,
                                       java.lang.Object b)
        Overrides:
        divide in class Type
      • modulo

        public java.lang.Object modulo(Session session,
                                       java.lang.Object a,
                                       java.lang.Object b,
                                       Type otherType)
      • absolute

        public java.lang.Object absolute(java.lang.Object a)
        Description copied from class: Type
        All arithmetic ops are called on the pre-determined Type object of the result
        Overrides:
        absolute in class Type
      • negate

        public java.lang.Object negate(java.lang.Object a)
        Overrides:
        negate in class Type
      • getNumericPrecisionInRadix

        public int getNumericPrecisionInRadix()
      • getIntegralType

        public Type getIntegralType()
      • isZero

        public static boolean isZero(java.lang.Object a)
      • isNegative

        public boolean isNegative(java.lang.Object a)
      • compareToZero

        public int compareToZero(java.lang.Object a)
      • scaledDecimal

        public static long scaledDecimal(java.lang.Object a,
                                         int scale)
      • isInLongLimits

        public static boolean isInLongLimits(java.math.BigDecimal result)
      • isInLongLimits

        public static boolean isInLongLimits(java.math.BigInteger result)
      • ceiling

        public java.lang.Object ceiling(java.lang.Object a)
      • floor

        public java.lang.Object floor(java.lang.Object a)
      • truncate

        public java.lang.Object truncate(java.lang.Object a,
                                         int s)
      • round

        public java.lang.Object round(java.lang.Object a,
                                      int s)
      • getNumberType

        public static NumberType getNumberType(int type,
                                               long precision,
                                               int scale)

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.