Package org.apache.derby.catalog.types
Class BaseTypeIdImpl
- java.lang.Object
-
- org.apache.derby.catalog.types.BaseTypeIdImpl
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,Formatable,TypedFormat
- Direct Known Subclasses:
DecimalTypeIdImpl,RowMultiSetImpl,UserDefinedTypeIdImpl
public class BaseTypeIdImpl extends java.lang.Object implements Formatable
This class is the base class for all type ids that are written to the system tables.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private intformatIdThis class implements Formatable.(package private) intJDBCTypeIdJDBC type - derived from the format identifier.protected java.lang.StringschemaName(package private) java.lang.StringunqualifiedName
-
Constructor Summary
Constructors Constructor Description BaseTypeIdImpl()niladic constructor.BaseTypeIdImpl(int formatId)1 argument constructor.BaseTypeIdImpl(java.lang.String SQLTypeName)Constructor for an BaseTypeIdImplBaseTypeIdImpl(java.lang.String schemaName, java.lang.String unqualifiedName)Constructor for an BaseTypeIdImpl which describes a UDT
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringdoubleQuote(java.lang.String raw)booleanequals(java.lang.Object that)we want equals to say if these are the same type id or not.intgetJDBCTypeId()Get the jdbc type id for this type.java.lang.StringgetSchemaName()Get the schema name of this type.java.lang.StringgetSQLTypeName()Returns the SQL name of the datatype.intgetTypeFormatId()Get the formatID which corresponds to this class.java.lang.StringgetUnqualifiedName()Get the unqualified name of this type.inthashCode()Hashcode which works with equals.booleanisAnsiUDT()Return true if this is this type id describes an ANSI UDTvoidreadExternal(java.io.ObjectInput in)Read this object from a stream of stored objects.private voidsetTypeIdSpecificInstanceVariables()private java.lang.StringstripQuotes(java.lang.String quoted)java.lang.StringtoParsableString(TypeDescriptor td)Converts this TypeId, given a data type descriptor (including length/precision), to a string.java.lang.StringtoString()Format this BaseTypeIdImpl as a StringbooleanuserType()Does this type id represent a user type?voidwriteExternal(java.io.ObjectOutput out)Write this object to a stream of stored objects.
-
-
-
Field Detail
-
formatId
private int formatId
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.
-
schemaName
protected java.lang.String schemaName
-
unqualifiedName
java.lang.String unqualifiedName
-
JDBCTypeId
transient int JDBCTypeId
JDBC type - derived from the format identifier.
-
-
Constructor Detail
-
BaseTypeIdImpl
public BaseTypeIdImpl()
niladic constructor. Needed for Formatable interface to work.
-
BaseTypeIdImpl
public BaseTypeIdImpl(int formatId)
1 argument constructor. Needed for Formatable interface to work.- Parameters:
formatId- Format id of specific type id.
-
BaseTypeIdImpl
BaseTypeIdImpl(java.lang.String SQLTypeName)
Constructor for an BaseTypeIdImpl- Parameters:
SQLTypeName- The unqualified SQL name of the type
-
BaseTypeIdImpl
BaseTypeIdImpl(java.lang.String schemaName, java.lang.String unqualifiedName)Constructor for an BaseTypeIdImpl which describes a UDT- Parameters:
schemaName- The schema that the UDT lives inunqualifiedName- The unqualified name of the UDT in that schema
-
-
Method Detail
-
getSQLTypeName
public java.lang.String getSQLTypeName()
Returns the SQL name of the datatype. If it is a Derby user-defined type, it returns the full Java path name for the datatype, meaning the dot-separated path including the package names. If it is a UDT, returns "schemaName"."unqualifiedName".- Returns:
- A String containing the SQL name of this type.
-
getSchemaName
public java.lang.String getSchemaName()
Get the schema name of this type. Non-null only for UDTs
-
getUnqualifiedName
public java.lang.String getUnqualifiedName()
Get the unqualified name of this type. Except for UDTs, this is the same value as getSQLTypeName()
-
isAnsiUDT
public boolean isAnsiUDT()
Return true if this is this type id describes an ANSI UDT
-
getJDBCTypeId
public int getJDBCTypeId()
Get the jdbc type id for this type. JDBC type can be found in java.sql.Types.- Returns:
- a jdbc type, e.g. java.sql.Types.DECIMAL
- See Also:
Types
-
toParsableString
public java.lang.String toParsableString(TypeDescriptor td)
Converts this TypeId, given a data type descriptor (including length/precision), to a string. E.g. VARCHAR(30) For most data types, we just return the SQL type name.- Parameters:
td- Data type descriptor that holds the length/precision etc. as necessary- Returns:
- String version of datatype, suitable for running through the Parser.
-
userType
public boolean userType()
Does this type id represent a user type?
-
toString
public java.lang.String toString()
Format this BaseTypeIdImpl as a String- Overrides:
toStringin classjava.lang.Object- Returns:
- This BaseTypeIdImpl formatted as a String
-
equals
public boolean equals(java.lang.Object that)
we want equals to say if these are the same type id or not.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Hashcode which works with equals.- Overrides:
hashCodein classjava.lang.Object
-
getTypeFormatId
public int getTypeFormatId()
Get the formatID which corresponds to this class.- Specified by:
getTypeFormatIdin interfaceTypedFormat- Returns:
- the formatID of this class
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundExceptionRead this object from a stream of stored objects.- Specified by:
readExternalin interfacejava.io.Externalizable- Parameters:
in- read this.- Throws:
java.io.IOException- thrown on errorjava.lang.ClassNotFoundException- thrown on error
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOExceptionWrite this object to a stream of stored objects.- Specified by:
writeExternalin interfacejava.io.Externalizable- Parameters:
out- write bytes here.- Throws:
java.io.IOException- thrown on error
-
setTypeIdSpecificInstanceVariables
private void setTypeIdSpecificInstanceVariables()
-
doubleQuote
private java.lang.String doubleQuote(java.lang.String raw)
-
stripQuotes
private java.lang.String stripQuotes(java.lang.String quoted)
-
-