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 intprivate booleanprivate intprivate intprivate intprivate BaseTypeIdImplThis class implements Formatable.Fields inherited from interface 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 descriptorsbooleanCompare if two TypeDescriptors are exactly the sameintGet the collation type for this type.intGet the jdbc type id for this type.intReturns the maximum width of the type.intReturn the length of this type in bytes.intReturns 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.intgetScale()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.intGet the formatID which corresponds to this class.Get the type Id stored within this type descriptor.Gets the name of this datatype.booleanReturns TRUE if the datatype can contain NULL, FALSE if not.booleanReturn true if this is a Row Multiset typebooleanReport whether this type is a string type.booleanReturn true if this is a user defined typevoidRead this object from a stream of stored objects.voidsetCollationType(int collationTypeValue) toString()voidWrite 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:TypeDescriptorReturns 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:
getMaximumWidthin 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:
getMaximumWidthInBytesin 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:
getJDBCTypeIdin interfaceTypeDescriptor- Returns:
- a jdbc type, e.g. java.sql.Types.DECIMAL
- See Also:
-
getTypeName
Gets the name of this datatype.- Specified by:
getTypeNamein interfaceTypeDescriptor- Returns:
- the name of this datatype
-
getPrecision
public int getPrecision()Returns the number of decimal digits for the datatype, if applicable.- Specified by:
getPrecisionin 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:
getScalein 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:
isNullablein interfaceTypeDescriptor- Returns:
- TRUE if the datatype can contain NULL, FALSE if not.
-
isRowMultiSet
public boolean isRowMultiSet()Description copied from interface:TypeDescriptorReturn true if this is a Row Multiset type- Specified by:
isRowMultiSetin interfaceTypeDescriptor- See Also:
-
isUserDefinedType
public boolean isUserDefinedType()Description copied from interface:TypeDescriptorReturn true if this is a user defined type- Specified by:
isUserDefinedTypein interfaceTypeDescriptor- See Also:
-
getCollationType
public int getCollationType()Description copied from interface:TypeDescriptorGet 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:
getCollationTypein 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:
getSQLstringin interfaceTypeDescriptor- Returns:
- String version of datatype, suitable for running through the Parser.
-
toString
-
getTypeId
Get the type Id stored within this type descriptor. -
equals
-
readExternal
Read this object from a stream of stored objects.- Specified by:
readExternalin 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:
writeExternalin 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:
getTypeFormatIdin interfaceTypedFormat- Returns:
- the formatID of this class
-
getRowColumnNames
Description copied from interface:TypeDescriptorIf this catalog type is a row multi-set type then return its array of column names.- Specified by:
getRowColumnNamesin interfaceTypeDescriptor- Returns:
- Column names comprising the row, null if this is not a row type.
-
getRowTypes
Description copied from interface:TypeDescriptorIf this catalog type is a row multi-set type then return its array of catalog types.- Specified by:
getRowTypesin interfaceTypeDescriptor- Returns:
- Catalog ypes comprising the row, null if this is not a row type.
-