Package org.apache.derby.catalog.types
Class TypeDescriptorImpl
java.lang.Object
org.apache.derby.catalog.types.TypeDescriptorImpl
- All Implemented Interfaces:
Externalizable
,Serializable
,TypeDescriptor
,Formatable
,TypedFormat
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private boolean
private int
private int
private int
private BaseTypeIdImpl
This class implements Formatable.Fields inherited from interface org.apache.derby.catalog.TypeDescriptor
DOUBLE, INTEGER, INTEGER_NOT_NULL, MAXIMUM_WIDTH_UNKNOWN, SMALLINT, SMALLINT_NOT_NULL
-
Constructor Summary
ConstructorsConstructorDescriptionPublic niladic constructor.TypeDescriptorImpl
(BaseTypeIdImpl typeId, boolean isNullable, int maximumWidth) Constructor for use with non-numeric typesTypeDescriptorImpl
(BaseTypeIdImpl typeId, int precision, int scale, boolean isNullable, int maximumWidth) Constructor for use with numeric typesTypeDescriptorImpl
(BaseTypeIdImpl typeId, int precision, int scale, boolean isNullable, int maximumWidth, int collationType) Constructor to use when the caller doesn't know if it is requesting numeric or no-numeric DTD.TypeDescriptorImpl
(TypeDescriptorImpl source, boolean isNullable, int maximumWidth) Constructor for internal uses onlyTypeDescriptorImpl
(TypeDescriptorImpl source, int precision, int scale, boolean isNullable, int maximumWidth) Constructor for internal uses only.TypeDescriptorImpl
(TypeDescriptorImpl source, int precision, int scale, boolean isNullable, int maximumWidth, int collationType) -
Method Summary
Modifier and TypeMethodDescriptionstatic TypeDescriptor[]
copyTypeDescriptors
(TypeDescriptor[] original) copy an array of type descriptorsboolean
Compare if two TypeDescriptors are exactly the sameint
Get the collation type for this type.int
Get the jdbc type id for this type.int
Returns the maximum width of the type.int
Return the length of this type in bytes.int
Returns the number of decimal digits for the datatype, if applicable.String[]
If this catalog type is a row multi-set type then return its array of column names.If this catalog type is a row multi-set type then return its array of catalog types.int
getScale()
Returns the number of digits to the right of the decimal for the datatype, if applicable.Converts this data type descriptor (including length/precision) to a string.int
Get the formatID which corresponds to this class.Get the type Id stored within this type descriptor.Gets the name of this datatype.boolean
Returns TRUE if the datatype can contain NULL, FALSE if not.boolean
Return true if this is a Row Multiset typeboolean
Report whether this type is a string type.boolean
Return true if this is a user defined typevoid
Read this object from a stream of stored objects.void
setCollationType
(int collationTypeValue) toString()
void
Write this object to a stream of stored objects.
-
Field Details
-
typeId
This class implements Formatable. That means that it can write itself to and from a formatted stream. If you add more fields to this class, make sure that you also write/read them with the writeExternal()/readExternal() methods. If, inbetween releases, you add more fields to this class, then you should bump the version number emitted by the getTypeFormatId() method. -
precision
private int precision -
scale
private int scale -
isNullable
private boolean isNullable -
maximumWidth
private int maximumWidth -
collationType
private int collationType- See Also:
-
-
Constructor Details
-
TypeDescriptorImpl
public TypeDescriptorImpl()Public niladic constructor. Needed for Formatable interface to work. -
TypeDescriptorImpl
public TypeDescriptorImpl(BaseTypeIdImpl typeId, int precision, int scale, boolean isNullable, int maximumWidth) Constructor for use with numeric types- Parameters:
typeId
- The typeId of the type being describedprecision
- The number of decimal digits.scale
- The number of digits after the decimal point.isNullable
- TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.maximumWidth
- The maximum number of bytes for this datatype
-
TypeDescriptorImpl
public TypeDescriptorImpl(BaseTypeIdImpl typeId, int precision, int scale, boolean isNullable, int maximumWidth, int collationType) Constructor to use when the caller doesn't know if it is requesting numeric or no-numeric DTD. For instance, when dealing with MAX/MIN aggregrate operators, AggregateNode.bindExpression could be dealing with a character string operand or a numeric operand. The result of MAX/MIN will depend on the type of it's operand. And hence when this constructor gets called by AggregateNode.bindExpression, we don't know what type we are constructing and hence this constructor supports arguments for both numeric and non-numeric types.- Parameters:
typeId
- The typeId of the type being describedprecision
- The number of decimal digits.scale
- The number of digits after the decimal point.isNullable
- TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.maximumWidth
- The maximum number of bytes for this datatypecollationType
- The collation type of a string data type
-
TypeDescriptorImpl
Constructor for use with non-numeric types- Parameters:
typeId
- The typeId of the type being describedisNullable
- TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.maximumWidth
- The maximum number of bytes for this datatype
-
TypeDescriptorImpl
public TypeDescriptorImpl(TypeDescriptorImpl source, int precision, int scale, boolean isNullable, int maximumWidth) Constructor for internal uses only. (This is useful when the precision and scale are potentially wider than those in the source, like when determining the dominant data type.)- Parameters:
source
- The DTSI to copyprecision
- The number of decimal digits.scale
- The number of digits after the decimal point.isNullable
- TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.maximumWidth
- The maximum number of bytes for this datatype
-
TypeDescriptorImpl
public TypeDescriptorImpl(TypeDescriptorImpl source, int precision, int scale, boolean isNullable, int maximumWidth, int collationType) -
TypeDescriptorImpl
Constructor for internal uses only- Parameters:
source
- The DTSI to copyisNullable
- TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.maximumWidth
- The maximum number of bytes for this datatype
-
-
Method Details
-
copyTypeDescriptors
copy an array of type descriptors -
getMaximumWidth
public int getMaximumWidth()Description copied from interface:TypeDescriptor
Returns the maximum width of the type. This may have different meanings for different types. For example, with char, it means the maximum number of characters, while with int, it is the number of bytes (i.e. 4).- Specified by:
getMaximumWidth
in interfaceTypeDescriptor
- Returns:
- the maximum length of this Type; -1 means "unknown/no max length"
- See Also:
-
getMaximumWidthInBytes
public int getMaximumWidthInBytes()Return the length of this type in bytes. Note that while the JDBC API _does_ define a need for returning length in bytes of a type, it doesn't state clearly what that means for the various types. We assume therefore that the values here are meant to match those specified by the ODBC specification (esp. since ODBC clients are more likely to need this value than a Java client). The ODBC spec that defines the values we use here can be found at the following link: http://msdn.microsoft.com/library/default.asp?url=/library/ en-us/odbc/htm/odbctransfer_octet_length.asp- Specified by:
getMaximumWidthInBytes
in interfaceTypeDescriptor
- Returns:
- the maximum length of this Type IN BYTES; -1 means "unknown/no max length"
- See Also:
-
isStringType
public boolean isStringType()Report whether this type is a string type. -
getJDBCTypeId
public int getJDBCTypeId()Get the jdbc type id for this type. JDBC type can be found in java.sql.Types.- Specified by:
getJDBCTypeId
in interfaceTypeDescriptor
- Returns:
- a jdbc type, e.g. java.sql.Types.DECIMAL
- See Also:
-
getTypeName
Gets the name of this datatype.- Specified by:
getTypeName
in interfaceTypeDescriptor
- Returns:
- the name of this datatype
-
getPrecision
public int getPrecision()Returns the number of decimal digits for the datatype, if applicable.- Specified by:
getPrecision
in interfaceTypeDescriptor
- Returns:
- The number of decimal digits for the datatype. Returns zero for non-numeric datatypes.
-
getScale
public int getScale()Returns the number of digits to the right of the decimal for the datatype, if applicable.- Specified by:
getScale
in interfaceTypeDescriptor
- Returns:
- The number of digits to the right of the decimal for the datatype. Returns zero for non-numeric datatypes.
-
isNullable
public boolean isNullable()Returns TRUE if the datatype can contain NULL, FALSE if not. JDBC supports a return value meaning "nullability unknown" - I assume we will never have columns where the nullability is unknown.- Specified by:
isNullable
in interfaceTypeDescriptor
- Returns:
- TRUE if the datatype can contain NULL, FALSE if not.
-
isRowMultiSet
public boolean isRowMultiSet()Description copied from interface:TypeDescriptor
Return true if this is a Row Multiset type- Specified by:
isRowMultiSet
in interfaceTypeDescriptor
- See Also:
-
isUserDefinedType
public boolean isUserDefinedType()Description copied from interface:TypeDescriptor
Return true if this is a user defined type- Specified by:
isUserDefinedType
in interfaceTypeDescriptor
- See Also:
-
getCollationType
public int getCollationType()Description copied from interface:TypeDescriptor
Get the collation type for this type. This api applies only to character string types. And its return value is valid only if the collation derivation of this type is "implicit" or "explicit". (In Derby 10.3, collation derivation can't be "explicit". Hence in Derby 10.3, this api should be used only if the collation derivation is "implicit".- Specified by:
getCollationType
in interfaceTypeDescriptor
- Returns:
- collation type which applies to character string types with collation derivation of "implicit" or "explicit". The possible return values in Derby 10.3 will be COLLATION_TYPE_UCS_BASIC and COLLATION_TYPE_TERRITORY_BASED.
- See Also:
-
setCollationType
public void setCollationType(int collationTypeValue) -
getSQLstring
Converts this data type descriptor (including length/precision) to a string. E.g. VARCHAR(30) or java.util.Hashtable- Specified by:
getSQLstring
in interfaceTypeDescriptor
- Returns:
- String version of datatype, suitable for running through the Parser.
-
toString
-
getTypeId
Get the type Id stored within this type descriptor. -
equals
Compare if two TypeDescriptors are exactly the same -
readExternal
Read this object from a stream of stored objects.- Specified by:
readExternal
in interfaceExternalizable
- Parameters:
in
- read this.- Throws:
IOException
- thrown on errorClassNotFoundException
- thrown on error
-
writeExternal
Write this object to a stream of stored objects.- Specified by:
writeExternal
in interfaceExternalizable
- Parameters:
out
- write bytes here.- Throws:
IOException
- thrown on error
-
getTypeFormatId
public int getTypeFormatId()Get the formatID which corresponds to this class.- Specified by:
getTypeFormatId
in interfaceTypedFormat
- Returns:
- the formatID of this class
-
getRowColumnNames
Description copied from interface:TypeDescriptor
If this catalog type is a row multi-set type then return its array of column names.- Specified by:
getRowColumnNames
in interfaceTypeDescriptor
- Returns:
- Column names comprising the row, null if this is not a row type.
-
getRowTypes
Description copied from interface:TypeDescriptor
If this catalog type is a row multi-set type then return its array of catalog types.- Specified by:
getRowTypes
in interfaceTypeDescriptor
- Returns:
- Catalog ypes comprising the row, null if this is not a row type.
-