public class BasicSqlType extends AbstractSqlType
Instances of this class are immutable.
| Modifier and Type | Field and Description |
|---|---|
protected RelDataTypeSystem |
typeSystem |
isNullable, typeNamedigest, fieldList, NON_NULLABLE_SUFFIXPRECISION_NOT_SPECIFIED, SCALE_NOT_SPECIFIED| Modifier | Constructor and Description |
|---|---|
|
BasicSqlType(RelDataTypeSystem typeSystem,
SqlTypeName typeName)
Constructs a type with no parameters.
|
protected |
BasicSqlType(RelDataTypeSystem typeSystem,
SqlTypeName typeName,
boolean nullable) |
|
BasicSqlType(RelDataTypeSystem typeSystem,
SqlTypeName typeName,
int precision)
Constructs a type with precision/length but no scale.
|
|
BasicSqlType(RelDataTypeSystem typeSystem,
SqlTypeName typeName,
int precision,
int scale)
Constructs a type with precision/length and scale.
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
checkPrecScale(SqlTypeName typeName,
boolean precisionSpecified,
boolean scaleSpecified)
Throws if
typeName does not allow the given combination of
precision and scale. |
protected void |
generateTypeString(StringBuilder sb,
boolean withDetail)
Generates a string representation of this type.
|
@Nullable Charset |
getCharset()
Gets this type's character set, or null if this type cannot carry a
character set or has no character set defined.
|
@Nullable SqlCollation |
getCollation()
Gets this type's collation, or null if this type cannot carry a collation
or has no collation defined.
|
@Nullable Object |
getLimit(boolean sign,
SqlTypeName.Limit limit,
boolean beyond)
Returns a value which is a limit for this type.
|
int |
getPrecision()
Gets the JDBC-defined precision for values of this type.
|
int |
getScale()
Gets the scale of this type.
|
getFamily, getPrecedenceList, getSqlTypeName, isNullablecomputeDigest, equals, extra, getComparability, getComponentType, getField, getFieldCount, getFieldList, getFieldMap, getFieldNames, getFullTypeString, getIntervalQualifier, getKeyType, getSqlIdentifier, getStructKind, getValueType, hashCode, isDynamicStruct, isStruct, proto, proto, proto, proto, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitequalsSansFieldNamesprotected final RelDataTypeSystem typeSystem
public BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName)
typeSystem - Type systemtypeName - Type nameprotected BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName, boolean nullable)
public BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName, int precision)
typeSystem - Type systemtypeName - Type nameprecision - Precision (called length for some types)public BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName, int precision, int scale)
typeSystem - Type systemtypeName - Type nameprecision - Precision (called length for some types)scale - Scaleprotected static void checkPrecScale(SqlTypeName typeName, boolean precisionSpecified, boolean scaleSpecified)
typeName does not allow the given combination of
precision and scale.public int getPrecision()
RelDataTypeReturns RelDataType.PRECISION_NOT_SPECIFIED (-1) if precision is not
applicable for this type.
getPrecision in interface RelDataTypegetPrecision in class RelDataTypeImplpublic int getScale()
RelDataTypeRelDataType.SCALE_NOT_SPECIFIED (-1) if
scale is not valid for this type.getScale in interface RelDataTypegetScale in class RelDataTypeImplpublic @Nullable Charset getCharset()
RelDataTypegetCharset in interface RelDataTypegetCharset in class RelDataTypeImplpublic @Nullable SqlCollation getCollation()
RelDataTypegetCollation in interface RelDataTypegetCollation in class RelDataTypeImplprotected void generateTypeString(StringBuilder sb, boolean withDetail)
RelDataTypeImplgenerateTypeString in class RelDataTypeImplsb - StringBuilder into which to generate the stringwithDetail - when true, all detail information needed to compute a
unique digest (and return from getFullTypeString) should
be included;public @Nullable Object getLimit(boolean sign, SqlTypeName.Limit limit, boolean beyond)
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' |
sign - If true, returns upper limit, otherwise lower limitlimit - If true, returns value at or near to overflow; otherwise
value at or near to underflowbeyond - If true, returns the value just beyond the limit, otherwise
the value at the limitCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.