Top Description Fields Methods
org.apache.derby.iapi.sql.compile

public Interface TypeCompiler

Known Direct Implementers
org.apache.derby.impl.sql.compile.BaseTypeCompiler
Imports
org.apache.derby.iapi.services.loader.ClassFactory, org.apache.derby.iapi.services.compiler.MethodBuilder, .LocalField, org.apache.derby.iapi.types.DataTypeDescriptor, .TypeId, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.Limits

This interface defines methods associated with a TypeId that are used by the compiler.

Field Summary

Modifier and TypeField and Description
public static final String
public static final int
public static final int
public static final int
public static final String
public static final int
public static final int
public static final int
LONGINT_MAXWIDTH_AS_CHAR

Various fixed numbers related to datatypes.

public static final int
public static final String
public static final String
public static final String
public static final int
public static final int
public static final String
public static final String
public static final int

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the types are compatible, false if not compatible
compatible
(TypeId
The CompilationType of the other type to compare this type to
otherType
)

Determine if this type is compatible to some other type (e.g. COALESCE(thistype, othertype)).

public boolean

Returns:

true if the types can be converted, false if conversion is not allowed
convertible
(TypeId
The CompilationType of the other type to compare this type to
otherType
,
boolean
true if this is a type function that requires more liberal behavior (e.g DOUBLE can convert a char but you cannot cast a CHAR to double.
forDataTypeFunction
)

Determine if this type can be CONVERTed to some other type

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
)

Generate the code necessary to produce a SQL value based on a value.

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
)

Generate the code necessary to produce a SQL null of the appropriate type.

public int

Returns:

int The maximum width for this data type when cast to a char type.
getCastToCharWidth
(DataTypeDescriptor
The associated DataTypeDescriptor for this TypeId.
dts
)

Return the maximum width for this data type when cast to a char type.

public String

Returns:

The name of the corresponding Java primitive type.
getCorrespondingPrimitiveTypeName
()

Get the name of the corresponding Java type.

public String

Returns:

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

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

public String

Returns:

The name of the interface for this type.
interfaceName
()

Get the name of the interface for this type.

public DataTypeDescriptor

Returns:

The type of the result
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
)

Type resolution methods on binary operators

public boolean

Returns:

true if the other type can be stored in a column of this type.
storable
(TypeId
The TypeId of the other type to compare this type to
otherType
,
ClassFactory
A ClassFactory
cf
)

Determine if this type can have a value of another type stored into it.

Field Detail

AVG_OPback to summary
public static final String AVG_OP
BOOLEAN_MAXWIDTH_AS_CHARback to summary
public static final int BOOLEAN_MAXWIDTH_AS_CHAR
DEFAULT_DECIMAL_PRECISIONback to summary
public static final int DEFAULT_DECIMAL_PRECISION
DEFAULT_DECIMAL_SCALEback to summary
public static final int DEFAULT_DECIMAL_SCALE
DIVIDE_OPback to summary
public static final String DIVIDE_OP
DOUBLE_MAXWIDTH_AS_CHARback to summary
public static final int DOUBLE_MAXWIDTH_AS_CHAR
INT_MAXWIDTH_AS_CHARback to summary
public static final int INT_MAXWIDTH_AS_CHAR
LONGINT_MAXWIDTH_AS_CHARback to summary
public static final int LONGINT_MAXWIDTH_AS_CHAR

Various fixed numbers related to datatypes.

MAX_DECIMAL_PRECISION_SCALEback to summary
public static final int MAX_DECIMAL_PRECISION_SCALE
MINUS_OPback to summary
public static final String MINUS_OP
MOD_OPback to summary
public static final String MOD_OP
PLUS_OPback to summary
public static final String PLUS_OP
REAL_MAXWIDTH_AS_CHARback to summary
public static final int REAL_MAXWIDTH_AS_CHAR
SMALLINT_MAXWIDTH_AS_CHARback to summary
public static final int SMALLINT_MAXWIDTH_AS_CHAR
SUM_OPback to summary
public static final String SUM_OP
TIMES_OPback to summary
public static final String TIMES_OP
TINYINT_MAXWIDTH_AS_CHARback to summary
public static final int TINYINT_MAXWIDTH_AS_CHAR

Method Detail

compatibleback to summary
public boolean compatible(TypeId otherType)

Determine if this type is compatible to some other type (e.g. COALESCE(thistype, othertype)).

Parameters
otherType:TypeId

The CompilationType of the other type to compare this type to

Returns:boolean

true if the types are compatible, false if not compatible

convertibleback to summary
public boolean convertible(TypeId otherType, boolean forDataTypeFunction)

Determine if this type can be CONVERTed to some other type

Parameters
otherType:TypeId

The CompilationType of the other type to compare this type to

forDataTypeFunction:boolean

true if this is a type function that requires more liberal behavior (e.g DOUBLE can convert a char but you cannot cast a CHAR to double.

Returns:boolean

true if the types can be converted, false if conversion is not allowed

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

Generate the code necessary to produce a SQL value based on a value. The value's type is assumed to match the type of this TypeId. For example, a TypeId for the SQL int type should be given an value that evaluates to a Java int or Integer. If the type of the value is incorrect, the generated code will not work. The stack must contain data value factory value.

Parameters
mb:MethodBuilder

The method to put the expression in

collationType: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.

field:LocalField

LocalField

generateNullback to summary
public void generateNull(MethodBuilder mb, int collationType)

Generate the code necessary to produce a SQL null of the appropriate type. The stack must contain a DataValueFactory and a null or a value of the correct type (interfaceName()).

Parameters
mb:MethodBuilder

The method to put the expression in

collationType: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.

getCastToCharWidthback to summary
public int getCastToCharWidth(DataTypeDescriptor dts)

Return the maximum width for this data type when cast to a char type.

Parameters
dts:DataTypeDescriptor

The associated DataTypeDescriptor for this TypeId.

Returns:int

int The maximum width for this data type when cast to a char type.

getCorrespondingPrimitiveTypeNameback to summary
public String getCorrespondingPrimitiveTypeName()

Get the name of the corresponding Java type. For numerics and booleans we will get the corresponding Java primitive type. e Each SQL type has a corresponding Java type. When a SQL value is passed to a Java method, it is translated to its corresponding Java type. For example, a SQL Integer will be mapped to a Java int, but a SQL date will be mapped to a java.sql.Date.

Returns:String

The name of the corresponding Java primitive type.

getPrimitiveMethodNameback to summary
public String getPrimitiveMethodName()

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

Returns:String

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

interfaceNameback to summary
public String interfaceName()

Get the name of the interface for this type. For example, the interface for a SQLInteger is NumberDataValue. The full path name of the type is returned.

Returns:String

The name of the interface for this type.

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

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
storableback to summary
public boolean storable(TypeId otherType, ClassFactory cf)

Determine if this type can have a value of another type stored into it. Note that direction is relevant here: the test is that the otherType is storable into this type.

Parameters
otherType:TypeId

The TypeId of the other type to compare this type to

cf:ClassFactory

A ClassFactory

Returns:boolean

true if the other type can be stored in a column of this type.