Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv abstract Class BaseTypeCompiler

extends Object
implements TypeCompiler
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.compile.TypeCompiler
Known Direct Subclasses
org.apache.derby.impl.sql.compile.BitTypeCompiler, org.apache.derby.impl.sql.compile.BooleanTypeCompiler, org.apache.derby.impl.sql.compile.CharTypeCompiler, org.apache.derby.impl.sql.compile.CLOBTypeCompiler, org.apache.derby.impl.sql.compile.DateTypeCompiler, org.apache.derby.impl.sql.compile.LOBTypeCompiler, org.apache.derby.impl.sql.compile.NumericTypeCompiler, org.apache.derby.impl.sql.compile.RefTypeCompiler, org.apache.derby.impl.sql.compile.TimestampTypeCompiler, org.apache.derby.impl.sql.compile.TimeTypeCompiler, org.apache.derby.impl.sql.compile.UserDefinedTypeCompiler, org.apache.derby.impl.sql.compile.XMLTypeCompiler
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.LocalField, .MethodBuilder, org.apache.derby.iapi.services.loader.ClassFactory, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.TypeCompiler, org.apache.derby.iapi.types.DataTypeDescriptor, .TypeId

This is the base implementation of TypeCompiler

Field Summary

Modifier and TypeField and Description
private TypeId

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv String
dataValueMethodName()

Return the method name to get a Derby DataValueDescriptor object of the correct type and set it to a specific value.

public void
generateDataValue(MethodBuilder
The method to put the expression in
mb
,
int
For character DVDs, this will be used to determine what Collator should be associated with the DVD which in turn will decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs. For other types of DVDs, this parameter will be ignored.
collationType
,
LocalField
LocalField
field
)

Implements org.apache.derby.iapi.sql.compile.TypeCompiler.generateDataValue.

The caller will have pushed a DataValueFactory and value of that can be converted to the correct type, e.g. int for a SQL INTEGER.

public void
generateNull(MethodBuilder
The method to put the expression in
mb
,
int
For character DVDs, this will be used to determine what Collator should be associated with the DVD which in turn will decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs.
collationType
)

Implements org.apache.derby.iapi.sql.compile.TypeCompiler.generateNull.

The caller will have pushed a DataValueFactory and a null or a value of the correct type (interfaceName()).

public String

Returns:

String The method call name for getting the corresponding primitive Java type.
getPrimitiveMethodName
()

Implements org.apache.derby.iapi.sql.compile.TypeCompiler.getPrimitiveMethodName.

Get the method name for getting out the corresponding primitive Java type.

protected int

Returns:

The StoredFormatId from the corresponding TypeId.
getStoredFormatIdFromTypeId
()

Get the StoredFormatId from the corresponding TypeId.

protected TypeCompiler
getTypeCompiler(TypeId typeId)

Get the TypeCompiler that corresponds to the given TypeId.

protected TypeId
getTypeId()

Get the TypeId that corresponds to this TypeCompiler.

pack-priv abstract String
nullMethodName()

Return the method name to get a Derby DataValueDescriptor object of the correct type set to SQL NULL.

pack-priv boolean
numberConvertible(TypeId
The TypeId of the other type.
otherType
,
boolean
was this called from a scalarFunction like CHAR() or DOUBLE()
forDataTypeFunction
)

Tell whether this numeric type can be converted to the given type.

pack-priv boolean
numberStorable(TypeId
The TypeId of this type
thisType
,
TypeId
The TypeId of the other type.
otherType
,
ClassFactory
A ClassFactory
cf
)

Tell whether this numeric type can be stored into from the given type.

pack-priv boolean

Returns:

true collationType will be pushed, false collationType will be ignored.
pushCollationForDataValue
(int
Collation type of character values.
collationType
)

Return true if the collationType is to be passed to the methods generated by generateNull and generateDataValue.

public DataTypeDescriptor
resolveArithmeticOperation(DataTypeDescriptor
The type of the left parameter
leftType
,
DataTypeDescriptor
The type of the right parameter
rightType
,
String
The name of the operator (e.g. "+").
operator
)

Implements org.apache.derby.iapi.sql.compile.TypeCompiler.resolveArithmeticOperation.

Type resolution methods on binary operators

pack-priv void
setTypeId(TypeId typeId)

Set the TypeCompiler that corresponds to the given TypeId.

protected boolean

Returns:

true if thisType is storable in otherType
userTypeStorable
(TypeId
The TypeId of the value to be stored
thisType
,
TypeId
The TypeId of the value to be stored in
otherType
,
ClassFactory cf)

Determine whether thisType is storable in otherType due to otherType being a user type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

correspondingTypeIdback to summary
private TypeId correspondingTypeId

Constructor Detail

BaseTypeCompilerback to summary
pack-priv BaseTypeCompiler()

Method Detail

dataValueMethodNameback to summary
pack-priv String dataValueMethodName()

Return the method name to get a Derby DataValueDescriptor object of the correct type and set it to a specific value. The method named will be called with two arguments, a value to set the returned value to and a holder object if pushCollationForDataValue() returns false. Otherwise three arguments, the third being the collationType. This implementation returns "getDataValue" to map to the overloaded methods DataValueFactory.getDataValue(type, dvd type)

generateDataValueback to summary
public void generateDataValue(MethodBuilder mb, int collationType, LocalField field)

Implements org.apache.derby.iapi.sql.compile.TypeCompiler.generateDataValue.

The caller will have pushed a DataValueFactory and value of that can be converted to the correct type, e.g. int for a SQL INTEGER. Thus upon entry the stack looks like: ...,dvf,value If field is not null then it is used as the holder of the generated DataValueDescriptor to avoid object creations on multiple passes through this code. The field may contain null or a valid value. This method then sets up to call the required method on DataValueFactory using the dataValueMethodName(). The value left on the stack will be a DataValueDescriptor of the correct type: If the field contained a valid value then generated code will return that value rather than a newly created object. If field was not-null then the generated code will set the value of field to be the return from the DataValueFactory method call. Thus if the field was empty (set to null) when this code is executed it will contain the newly generated value, otherwise it will be reset to the same value. ...,dvd

Parameters
mb:MethodBuilder

Doc from org.apache.derby.iapi.sql.compile.TypeCompiler.generateDataValue.

The method to put the expression in

collationType:int

Doc from org.apache.derby.iapi.sql.compile.TypeCompiler.generateDataValue.

For character DVDs, this will be used to determine what Collator should be associated with the DVD which in turn will decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs. For other types of DVDs, this parameter will be ignored.

field:LocalField

Doc from org.apache.derby.iapi.sql.compile.TypeCompiler.generateDataValue.

LocalField

See Also
TypeCompiler#generateDataValue(MethodBuilder, int, LocalField)
generateNullback to summary
public void generateNull(MethodBuilder mb, int collationType)

Implements org.apache.derby.iapi.sql.compile.TypeCompiler.generateNull.

The caller will have pushed a DataValueFactory and a null or a value of the correct type (interfaceName()). Thus upon entry the stack looks like on of: ...,dvf,ref ...,dvf,null This method then sets up to call the required method on DataValueFactory using the nullMethodName(). The value left on the stack will be a DataValueDescriptor of the correct type: ...,dvd

Parameters
mb:MethodBuilder

Doc from org.apache.derby.iapi.sql.compile.TypeCompiler.generateNull.

The method to put the expression in

collationType:int

Doc from org.apache.derby.iapi.sql.compile.TypeCompiler.generateNull.

For character DVDs, this will be used to determine what Collator should be associated with the DVD which in turn will decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs.

See Also
TypeCompiler#generateNull(MethodBuilder, int)
getPrimitiveMethodNameback to summary
public String getPrimitiveMethodName()

Implements org.apache.derby.iapi.sql.compile.TypeCompiler.getPrimitiveMethodName.

Get the method name for getting out the corresponding primitive Java type.

Returns:String

String The method call name for getting the corresponding primitive Java type.

getStoredFormatIdFromTypeIdback to summary
protected int getStoredFormatIdFromTypeId()

Get the StoredFormatId from the corresponding TypeId.

Returns:int

The StoredFormatId from the corresponding TypeId.

getTypeCompilerback to summary
protected TypeCompiler getTypeCompiler(TypeId typeId)

Get the TypeCompiler that corresponds to the given TypeId.

getTypeIdback to summary
protected TypeId getTypeId()

Get the TypeId that corresponds to this TypeCompiler.

nullMethodNameback to summary
pack-priv abstract String nullMethodName()

Return the method name to get a Derby DataValueDescriptor object of the correct type set to SQL NULL. The method named will be called with one argument: a holder object if pushCollationForDataValue() returns false, otherwise two arguments, the second being the collationType.

numberConvertibleback to summary
pack-priv boolean numberConvertible(TypeId otherType, boolean forDataTypeFunction)

Tell whether this numeric type can be converted to the given type.

Parameters
otherType:TypeId

The TypeId of the other type.

forDataTypeFunction:boolean

was this called from a scalarFunction like CHAR() or DOUBLE()

numberStorableback to summary
pack-priv boolean numberStorable(TypeId thisType, TypeId otherType, ClassFactory cf)

Tell whether this numeric type can be stored into from the given type.

Parameters
thisType:TypeId

The TypeId of this type

otherType:TypeId

The TypeId of the other type.

cf:ClassFactory

A ClassFactory

pushCollationForDataValueback to summary
pack-priv boolean pushCollationForDataValue(int collationType)

Return true if the collationType is to be passed to the methods generated by generateNull and generateDataValue.

Parameters
collationType:int

Collation type of character values.

Returns:boolean

true collationType will be pushed, false collationType will be ignored.

resolveArithmeticOperationback to summary
public DataTypeDescriptor resolveArithmeticOperation(DataTypeDescriptor leftType, DataTypeDescriptor rightType, String operator) throws StandardException

Implements org.apache.derby.iapi.sql.compile.TypeCompiler.resolveArithmeticOperation.

Doc from org.apache.derby.iapi.sql.compile.TypeCompiler.resolveArithmeticOperation.

Type resolution methods on binary operators

Parameters
leftType:DataTypeDescriptor

The type of the left parameter

rightType:DataTypeDescriptor

The type of the right parameter

operator:String

The name of the operator (e.g. "+").

Returns:DataTypeDescriptor

The type of the result

Exceptions
StandardException:
Thrown on error
See Also
TypeCompiler#resolveArithmeticOperation
setTypeIdback to summary
pack-priv void setTypeId(TypeId typeId)

Set the TypeCompiler that corresponds to the given TypeId.

userTypeStorableback to summary
protected boolean userTypeStorable(TypeId thisType, TypeId otherType, ClassFactory cf)

Determine whether thisType is storable in otherType due to otherType being a user type.

Parameters
thisType:TypeId

The TypeId of the value to be stored

otherType:TypeId

The TypeId of the value to be stored in

Returns:boolean

true if thisType is storable in otherType