org.apache.derby.catalog.types
Class TypeDescriptorImpl

java.lang.Object
  extended byorg.apache.derby.catalog.types.TypeDescriptorImpl
All Implemented Interfaces:
java.io.Externalizable, Formatable, java.io.Serializable, TypeDescriptor, TypedFormat

public class TypeDescriptorImpl
extends java.lang.Object
implements TypeDescriptor, Formatable

See Also:
Serialized Form

Field Summary
private  boolean isNullable
           
private  int maximumWidth
           
private  int precision
           
private  int scale
           
private  BaseTypeIdImpl typeId
          This class implements Formatable.
 
Fields inherited from interface org.apache.derby.catalog.TypeDescriptor
MAXIMUM_WIDTH_UNKNOWN
 
Constructor Summary
TypeDescriptorImpl()
          Public niladic constructor.
TypeDescriptorImpl(BaseTypeIdImpl typeId, boolean isNullable, int maximumWidth)
          Constructor for use with non-numeric types
TypeDescriptorImpl(BaseTypeIdImpl typeId, int precision, int scale, boolean isNullable, int maximumWidth)
          Constructor for use with numeric types
TypeDescriptorImpl(TypeDescriptorImpl source, boolean isNullable, int maximumWidth)
          Constructor for internal uses only
TypeDescriptorImpl(TypeDescriptorImpl source, int precision, int scale, boolean isNullable, int maximumWidth)
          Constructor for internal uses only.
 
Method Summary
 boolean equals(java.lang.Object object)
          Compare if two TypeDescriptors are exactly the same
 int getJDBCTypeId()
          Get the jdbc type id for this type.
 int getMaximumWidth()
          Returns the maximum width of the type.
 int getPrecision()
          Returns the number of decimal digits for the datatype, if applicable.
 int getScale()
          Returns the number of digits to the right of the decimal for the datatype, if applicable.
 java.lang.String getSQLstring()
          Converts this data type descriptor (including length/precision) to a string.
 int getTypeFormatId()
          Get the formatID which corresponds to this class.
 BaseTypeIdImpl getTypeId()
          Get the type Id stored within this type descriptor.
 java.lang.String getTypeName()
          Gets the name of this datatype.
 boolean isNullable()
          Returns TRUE if the datatype can contain NULL, FALSE if not.
 void readExternal(java.io.ObjectInput in)
          Read this object from a stream of stored objects.
 void setNullability(boolean nullable)
          Set the nullability of the datatype described by this descriptor
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
          Write this object to a stream of stored objects.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

typeId

private BaseTypeIdImpl 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
Constructor Detail

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 described
precision - 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,
                          boolean isNullable,
                          int maximumWidth)
Constructor for use with non-numeric types

Parameters:
typeId - The typeId of the type being described
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)
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 copy
precision - 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,
                          boolean isNullable,
                          int maximumWidth)
Constructor for internal uses only

Parameters:
source - The DTSI to copy
isNullable - TRUE means it could contain NULL, FALSE means it definitely cannot contain NULL.
maximumWidth - The maximum number of bytes for this datatype
Method Detail

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 interface TypeDescriptor
Returns:
the maximum length of this Type; -1 means "unknown/no max length"
See Also:
TypeDescriptor.getMaximumWidth()

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 interface TypeDescriptor
Returns:
a jdbc type, e.g. java.sql.Types.DECIMAL
See Also:
Types

getTypeName

public java.lang.String getTypeName()
Gets the name of this datatype.

Specified by:
getTypeName in interface TypeDescriptor
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 interface TypeDescriptor
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 interface TypeDescriptor
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 interface TypeDescriptor
Returns:
TRUE if the datatype can contain NULL, FALSE if not.

setNullability

public void setNullability(boolean nullable)
Set the nullability of the datatype described by this descriptor

Parameters:
nullable - TRUE means set nullability to TRUE, FALSE means set it to FALSE

getSQLstring

public java.lang.String getSQLstring()
Converts this data type descriptor (including length/precision) to a string. E.g. VARCHAR(30) or java.util.Hashtable

Specified by:
getSQLstring in interface TypeDescriptor
Returns:
String version of datatype, suitable for running through the Parser.

toString

public java.lang.String toString()

getTypeId

public BaseTypeIdImpl getTypeId()
Get the type Id stored within this type descriptor.


equals

public boolean equals(java.lang.Object object)
Compare if two TypeDescriptors are exactly the same


readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read this object from a stream of stored objects.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - read this.
Throws:
java.io.IOException - thrown on error
java.lang.ClassNotFoundException - thrown on error

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Write this object to a stream of stored objects.

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - write bytes here.
Throws:
java.io.IOException - thrown on error

getTypeFormatId

public int getTypeFormatId()
Get the formatID which corresponds to this class.

Specified by:
getTypeFormatId in interface TypedFormat
Returns:
the formatID of this class


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.