org.eigenbase.sql.type
Enum SqlTypeName

java.lang.Object
  extended by java.lang.Enum<SqlTypeName>
      extended by org.eigenbase.sql.type.SqlTypeName
All Implemented Interfaces:
Serializable, Comparable<SqlTypeName>

public enum SqlTypeName
extends Enum<SqlTypeName>

Enumeration of the type names which can be used to construct a SQL type. Rationale for this class's existence (instead of just using the standard java.sql.Type ordinals):

Since:
Nov 24, 2003
Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/type/SqlTypeName.java#35 $
Author:
jhyde

Nested Class Summary
static class SqlTypeName.Limit
           
private static interface SqlTypeName.PrecScale
          Flags indicating precision/scale combinations.
 
Enum Constant Summary
ANY
           
BIGINT
           
BINARY
           
BOOLEAN
           
CHAR
           
COLUMN_LIST
           
CURSOR
           
DATE
           
DECIMAL
           
DISTINCT
           
DOUBLE
           
FLOAT
           
INTEGER
           
INTERVAL_DAY_TIME
           
INTERVAL_YEAR_MONTH
           
MULTISET
           
NULL
           
REAL
           
ROW
           
SMALLINT
           
STRUCTURED
           
SYMBOL
           
TIME
           
TIMESTAMP
           
TINYINT
           
VARBINARY
           
VARCHAR
           
 
Field Summary
static SqlTypeName[] allTypes
           
static SqlTypeName[] approxTypes
           
static SqlTypeName[] binaryTypes
           
static SqlTypeName[] booleanTypes
           
static SqlTypeName[] charTypes
           
static SqlTypeName[] columnListTypes
           
static SqlTypeName[] cursorTypes
           
static SqlTypeName[] datetimeTypes
           
static int DEFAULT_INTERVAL_FRACTIONAL_SECOND_PRECISION
           
static int DEFAULT_INTERVAL_START_PRECISION
           
static SqlTypeName[] EMPTY_ARRAY
           
static SqlTypeName[] exactTypes
           
static SqlTypeName[] fractionalTypes
           
static SqlTypeName[] intTypes
           
private  int jdbcOrdinal
           
private static SqlTypeName[] jdbcTypeToName
           
static int MAX_BINARY_LENGTH
           
static int MAX_CHAR_LENGTH
           
static int MAX_DATETIME_PRECISION
           
static int MAX_INTERVAL_FRACTIONAL_SECOND_PRECISION
           
static int MAX_INTERVAL_START_PRECISION
           
static int MAX_JDBC_TYPE
           
static int MAX_NUMERIC_PRECISION
           
static int MAX_NUMERIC_SCALE
           
static int MIN_INTERVAL_FRACTIONAL_SECOND_PRECISION
           
static int MIN_INTERVAL_START_PRECISION
           
static int MIN_JDBC_TYPE
           
static SqlTypeName[] multisetTypes
           
static SqlTypeName[] numericTypes
           
private  int signatures
          Bitwise-or of flags indicating allowable precision/scale combinations.
private  boolean special
          Returns true if not of a "pure" standard sql type.
static SqlTypeName[] stringTypes
           
static SqlTypeName[] timeIntervalTypes
           
private static Map<String,SqlTypeName> VALUES_MAP
           
 
Method Summary
 boolean allowsNoPrecNoScale()
           
 boolean allowsPrec()
           
 boolean allowsPrecNoScale()
           
 boolean allowsPrecScale(boolean precision, boolean scale)
          Returns whether this type can be specified with a given combination of precision and scale.
 boolean allowsScale()
           
private static SqlTypeName[] combine(SqlTypeName[] array0, SqlTypeName[] array1)
           
 SqlLiteral createLiteral(Object o, SqlParserPos pos)
           
static SqlTypeName get(String name)
          Looks up a type name from its name.
 int getDefaultPrecision()
           
 int getDefaultScale()
           
 SqlTypeFamily getFamily()
          Gets the SqlTypeFamily containing this SqlTypeName.
 int getJdbcOrdinal()
           
 Object getLimit(boolean sign, SqlTypeName.Limit limit, boolean beyond, int precision, int scale)
          Returns the limit of this datatype.
 int getMaxPrecision()
          Returns the maximum precision (or length) allowed for this type, or -1 if precision/length are not applicable for this type.
 int getMaxScale()
          Returns the maximum scale (or fractional second precision in the case of intervals) allowed for this type, or -1 if precision/length are not applicable for this type.
 int getMinPrecision()
          Returns the minimum precision (or length) allowed for this type, or -1 if precision/length are not applicable for this type.
 int getMinScale()
          Returns the minimum scale (or fractional second precision in the case of intervals) allowed for this type, or -1 if precision/length are not applicable for this type.
 String getName()
           
static SqlTypeName getNameForJdbcType(int jdbcType)
          Gets the SqlTypeName corresponding to a JDBC type.
private  BigDecimal getNumericLimit(int radix, int exponent, boolean sign, SqlTypeName.Limit limit, boolean beyond)
           
 boolean isSpecial()
           
private static void setNameForJdbcType(int jdbcType, SqlTypeName name)
           
static SqlTypeName valueOf(String name)
          Returns the enum constant of this type with the specified name.
static SqlTypeName[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

BOOLEAN

public static final SqlTypeName BOOLEAN

TINYINT

public static final SqlTypeName TINYINT

SMALLINT

public static final SqlTypeName SMALLINT

INTEGER

public static final SqlTypeName INTEGER

BIGINT

public static final SqlTypeName BIGINT

DECIMAL

public static final SqlTypeName DECIMAL

FLOAT

public static final SqlTypeName FLOAT

REAL

public static final SqlTypeName REAL

DOUBLE

public static final SqlTypeName DOUBLE

DATE

public static final SqlTypeName DATE

TIME

public static final SqlTypeName TIME

TIMESTAMP

public static final SqlTypeName TIMESTAMP

INTERVAL_YEAR_MONTH

public static final SqlTypeName INTERVAL_YEAR_MONTH

INTERVAL_DAY_TIME

public static final SqlTypeName INTERVAL_DAY_TIME

CHAR

public static final SqlTypeName CHAR

VARCHAR

public static final SqlTypeName VARCHAR

BINARY

public static final SqlTypeName BINARY

VARBINARY

public static final SqlTypeName VARBINARY

NULL

public static final SqlTypeName NULL

ANY

public static final SqlTypeName ANY

SYMBOL

public static final SqlTypeName SYMBOL

MULTISET

public static final SqlTypeName MULTISET

DISTINCT

public static final SqlTypeName DISTINCT

STRUCTURED

public static final SqlTypeName STRUCTURED

ROW

public static final SqlTypeName ROW

CURSOR

public static final SqlTypeName CURSOR

COLUMN_LIST

public static final SqlTypeName COLUMN_LIST
Field Detail

EMPTY_ARRAY

public static final SqlTypeName[] EMPTY_ARRAY

jdbcTypeToName

private static SqlTypeName[] jdbcTypeToName

MIN_JDBC_TYPE

public static final int MIN_JDBC_TYPE
See Also:
Constant Field Values

MAX_JDBC_TYPE

public static final int MAX_JDBC_TYPE
See Also:
Constant Field Values

MAX_DATETIME_PRECISION

public static final int MAX_DATETIME_PRECISION
See Also:
Constant Field Values

MAX_NUMERIC_PRECISION

public static final int MAX_NUMERIC_PRECISION
See Also:
Constant Field Values

MAX_NUMERIC_SCALE

public static final int MAX_NUMERIC_SCALE
See Also:
Constant Field Values

MAX_CHAR_LENGTH

public static final int MAX_CHAR_LENGTH
See Also:
Constant Field Values

MAX_BINARY_LENGTH

public static final int MAX_BINARY_LENGTH
See Also:
Constant Field Values

DEFAULT_INTERVAL_START_PRECISION

public static final int DEFAULT_INTERVAL_START_PRECISION
See Also:
Constant Field Values

DEFAULT_INTERVAL_FRACTIONAL_SECOND_PRECISION

public static final int DEFAULT_INTERVAL_FRACTIONAL_SECOND_PRECISION
See Also:
Constant Field Values

MIN_INTERVAL_START_PRECISION

public static final int MIN_INTERVAL_START_PRECISION
See Also:
Constant Field Values

MIN_INTERVAL_FRACTIONAL_SECOND_PRECISION

public static final int MIN_INTERVAL_FRACTIONAL_SECOND_PRECISION
See Also:
Constant Field Values

MAX_INTERVAL_START_PRECISION

public static final int MAX_INTERVAL_START_PRECISION
See Also:
Constant Field Values

MAX_INTERVAL_FRACTIONAL_SECOND_PRECISION

public static final int MAX_INTERVAL_FRACTIONAL_SECOND_PRECISION
See Also:
Constant Field Values

VALUES_MAP

private static final Map<String,SqlTypeName> VALUES_MAP

allTypes

public static final SqlTypeName[] allTypes

booleanTypes

public static final SqlTypeName[] booleanTypes

binaryTypes

public static final SqlTypeName[] binaryTypes

intTypes

public static final SqlTypeName[] intTypes

exactTypes

public static final SqlTypeName[] exactTypes

approxTypes

public static final SqlTypeName[] approxTypes

numericTypes

public static final SqlTypeName[] numericTypes

fractionalTypes

public static final SqlTypeName[] fractionalTypes

charTypes

public static final SqlTypeName[] charTypes

stringTypes

public static final SqlTypeName[] stringTypes

datetimeTypes

public static final SqlTypeName[] datetimeTypes

timeIntervalTypes

public static final SqlTypeName[] timeIntervalTypes

multisetTypes

public static final SqlTypeName[] multisetTypes

cursorTypes

public static final SqlTypeName[] cursorTypes

columnListTypes

public static final SqlTypeName[] columnListTypes

signatures

private final int signatures
Bitwise-or of flags indicating allowable precision/scale combinations.


special

private final boolean special
Returns true if not of a "pure" standard sql type. "Inpure" types are ANY, NULL and SYMBOL


jdbcOrdinal

private final int jdbcOrdinal
Method Detail

values

public static final SqlTypeName[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(SqlTypeName c : SqlTypeName.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static SqlTypeName valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name

get

public static SqlTypeName get(String name)
Looks up a type name from its name.

Returns:
Type name, or null if not found

allowsNoPrecNoScale

public boolean allowsNoPrecNoScale()

allowsPrecNoScale

public boolean allowsPrecNoScale()

allowsPrec

public boolean allowsPrec()

allowsScale

public boolean allowsScale()

allowsPrecScale

public boolean allowsPrecScale(boolean precision,
                               boolean scale)
Returns whether this type can be specified with a given combination of precision and scale. For example,

Parameters:
precision - Whether the precision/length field is part of the type specification
scale - Whether the scale field is part of the type specification
Returns:
Whether this combination of precision/scale is valid

isSpecial

public boolean isSpecial()

getJdbcOrdinal

public int getJdbcOrdinal()
Returns:
the ordinal from Types corresponding to this SqlTypeName

combine

private static SqlTypeName[] combine(SqlTypeName[] array0,
                                     SqlTypeName[] array1)

getDefaultPrecision

public int getDefaultPrecision()
Returns:
default precision for this type if supported, otherwise -1 if precision is either unsupported or must be specified explicitly

getDefaultScale

public int getDefaultScale()
Returns:
default scale for this type if supported, otherwise -1 if scale is either unsupported or must be specified explicitly

getFamily

public SqlTypeFamily getFamily()
Gets the SqlTypeFamily containing this SqlTypeName.

Returns:
containing family, or null for none

getNameForJdbcType

public static SqlTypeName getNameForJdbcType(int jdbcType)
Gets the SqlTypeName corresponding to a JDBC type.

Parameters:
jdbcType - the JDBC type of interest
Returns:
corresponding SqlTypeName

setNameForJdbcType

private static void setNameForJdbcType(int jdbcType,
                                       SqlTypeName name)

getLimit

public Object getLimit(boolean sign,
                       SqlTypeName.Limit limit,
                       boolean beyond,
                       int precision,
                       int scale)
Returns the limit of this datatype. For example,
Datatype sign limit beyond precision scale Returns
Integer true true false -1 -1 2147483647 (2 ^ 31 -1 = MAXINT)
Integer true true true -1 -1 2147483648 (2 ^ 31 = MAXINT + 1)
Integer false true false -1 -1 -2147483648 (-2 ^ 31 = MININT)
Boolean true true false -1 -1 TRUE
Varchar true true false 10 -1 'ZZZZZZZZZZ'

Parameters:
sign - If true, returns upper limit, otherwise lower limit
limit - If true, returns value at or near to overflow; otherwise value at or near to underflow
beyond - If true, returns the value just beyond the limit, otherwise the value at the limit
precision - Precision, or -1 if not applicable
scale - Scale, or -1 if not applicable
Returns:
Limit value

getMaxPrecision

public int getMaxPrecision()
Returns the maximum precision (or length) allowed for this type, or -1 if precision/length are not applicable for this type.

Returns:
Maximum allowed precision

getMaxScale

public int getMaxScale()
Returns the maximum scale (or fractional second precision in the case of intervals) allowed for this type, or -1 if precision/length are not applicable for this type.

Returns:
Maximum allowed scale

getMinPrecision

public int getMinPrecision()
Returns the minimum precision (or length) allowed for this type, or -1 if precision/length are not applicable for this type.

Returns:
Minimum allowed precision

getMinScale

public int getMinScale()
Returns the minimum scale (or fractional second precision in the case of intervals) allowed for this type, or -1 if precision/length are not applicable for this type.

Returns:
Minimum allowed scale

getNumericLimit

private BigDecimal getNumericLimit(int radix,
                                   int exponent,
                                   boolean sign,
                                   SqlTypeName.Limit limit,
                                   boolean beyond)

createLiteral

public SqlLiteral createLiteral(Object o,
                                SqlParserPos pos)

getName

public String getName()
Returns:
name of this type