public class BasicSqlType extends AbstractSqlType
Instances of this class are immutable.
Modifier and Type | Field and Description |
---|---|
private SqlCollation |
collation |
private int |
precision |
private int |
scale |
private RelDataTypeSystem |
typeSystem |
private SerializableCharset |
wrappedCharset |
isNullable, typeName
digest, fieldList
PRECISION_NOT_SPECIFIED, SCALE_NOT_SPECIFIED
Modifier | Constructor and Description |
---|---|
|
BasicSqlType(RelDataTypeSystem typeSystem,
SqlTypeName typeName)
Constructs a type with no parameters.
|
private |
BasicSqlType(RelDataTypeSystem typeSystem,
SqlTypeName typeName,
boolean nullable,
int precision,
int scale,
SqlCollation collation,
SerializableCharset wrappedCharset)
Internal constructor.
|
|
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. |
(package private) BasicSqlType |
createWithCharsetAndCollation(java.nio.charset.Charset charset,
SqlCollation collation)
Constructs a type with charset and collation.
|
(package private) BasicSqlType |
createWithNullability(boolean nullable)
Constructs a type with nullablity.
|
protected void |
generateTypeString(java.lang.StringBuilder sb,
boolean withDetail)
Generates a string representation of this type.
|
java.nio.charset.Charset |
getCharset()
Gets this type's character set, or null if this type cannot carry a
character set or has no character set defined.
|
SqlCollation |
getCollation()
Gets this type's collation, or null if this type cannot carry a collation
or has no collation defined.
|
java.lang.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, isNullable
computeDigest, equals, extra, getComparability, getComponentType, getField, getFieldCount, getFieldList, getFieldNames, getFullTypeString, getIntervalQualifier, getKeyType, getSqlIdentifier, getStructKind, getValueType, hashCode, isDynamicStruct, isStruct, proto, proto, proto, proto, toString
private final int precision
private final int scale
private final RelDataTypeSystem typeSystem
private final SqlCollation collation
private final SerializableCharset wrappedCharset
public BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName)
typeSystem
- Type systemtypeName
- Type namepublic 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
- Scaleprivate BasicSqlType(RelDataTypeSystem typeSystem, SqlTypeName typeName, boolean nullable, int precision, int scale, SqlCollation collation, SerializableCharset wrappedCharset)
protected static void checkPrecScale(SqlTypeName typeName, boolean precisionSpecified, boolean scaleSpecified)
typeName
does not allow the given combination of
precision and scale.BasicSqlType createWithNullability(boolean nullable)
BasicSqlType createWithCharsetAndCollation(java.nio.charset.Charset charset, SqlCollation collation)
This must be a character type.
public int getPrecision()
RelDataType
Returns RelDataType.PRECISION_NOT_SPECIFIED
(-1) if precision is not
applicable for this type.
getPrecision
in interface RelDataType
getPrecision
in class RelDataTypeImpl
public int getScale()
RelDataType
RelDataType.SCALE_NOT_SPECIFIED
(-1) if
scale is not valid for this type.getScale
in interface RelDataType
getScale
in class RelDataTypeImpl
public java.nio.charset.Charset getCharset()
RelDataType
getCharset
in interface RelDataType
getCharset
in class RelDataTypeImpl
public SqlCollation getCollation()
RelDataType
getCollation
in interface RelDataType
getCollation
in class RelDataTypeImpl
protected void generateTypeString(java.lang.StringBuilder sb, boolean withDetail)
RelDataTypeImpl
generateTypeString
in class RelDataTypeImpl
sb
- 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 java.lang.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–2019 The Apache Software Foundation. All rights reserved.