Interface TypeCompiler
- All Known Implementing Classes:
BaseTypeCompiler
,BitTypeCompiler
,BooleanTypeCompiler
,CharTypeCompiler
,CLOBTypeCompiler
,DateTypeCompiler
,LOBTypeCompiler
,NumericTypeCompiler
,RefTypeCompiler
,TimestampTypeCompiler
,TimeTypeCompiler
,UserDefinedTypeCompiler
,XMLTypeCompiler
public interface TypeCompiler
This interface defines methods associated with a TypeId that are used
by the compiler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final int
static final int
static final int
static final String
static final int
static final int
static final int
Various fixed numbers related to datatypes.static final int
static final String
static final String
static final String
static final int
static final int
static final String
static final String
static final int
-
Method Summary
Modifier and TypeMethodDescriptionboolean
compatible
(TypeId otherType) Determine if this type is compatible to some other type (e.g.boolean
convertible
(TypeId otherType, boolean forDataTypeFunction) Determine if this type can be CONVERTed to some other typevoid
generateDataValue
(MethodBuilder mb, int collationType, LocalField field) Generate the code necessary to produce a SQL value based on a value.void
generateNull
(MethodBuilder mb, int collationType) Generate the code necessary to produce a SQL null of the appropriate type.int
Return the maximum width for this data type when cast to a char type.Get the name of the corresponding Java type.Get the method name for getting out the corresponding primitive Java type from a DataValueDescriptor.Get the name of the interface for this type.resolveArithmeticOperation
(DataTypeDescriptor leftType, DataTypeDescriptor rightType, String operator) Type resolution methods on binary operatorsboolean
storable
(TypeId otherType, ClassFactory cf) Determine if this type can have a value of another type stored into it.
-
Field Details
-
LONGINT_MAXWIDTH_AS_CHAR
static final int LONGINT_MAXWIDTH_AS_CHARVarious fixed numbers related to datatypes.- See Also:
-
INT_MAXWIDTH_AS_CHAR
static final int INT_MAXWIDTH_AS_CHAR- See Also:
-
SMALLINT_MAXWIDTH_AS_CHAR
static final int SMALLINT_MAXWIDTH_AS_CHAR- See Also:
-
TINYINT_MAXWIDTH_AS_CHAR
static final int TINYINT_MAXWIDTH_AS_CHAR- See Also:
-
DOUBLE_MAXWIDTH_AS_CHAR
static final int DOUBLE_MAXWIDTH_AS_CHAR- See Also:
-
REAL_MAXWIDTH_AS_CHAR
static final int REAL_MAXWIDTH_AS_CHAR- See Also:
-
DEFAULT_DECIMAL_PRECISION
static final int DEFAULT_DECIMAL_PRECISION- See Also:
-
DEFAULT_DECIMAL_SCALE
static final int DEFAULT_DECIMAL_SCALE- See Also:
-
MAX_DECIMAL_PRECISION_SCALE
static final int MAX_DECIMAL_PRECISION_SCALE- See Also:
-
BOOLEAN_MAXWIDTH_AS_CHAR
static final int BOOLEAN_MAXWIDTH_AS_CHAR- See Also:
-
PLUS_OP
- See Also:
-
DIVIDE_OP
- See Also:
-
MINUS_OP
- See Also:
-
TIMES_OP
- See Also:
-
SUM_OP
- See Also:
-
AVG_OP
- See Also:
-
MOD_OP
- See Also:
-
-
Method Details
-
resolveArithmeticOperation
DataTypeDescriptor resolveArithmeticOperation(DataTypeDescriptor leftType, DataTypeDescriptor rightType, String operator) throws StandardException Type resolution methods on binary operators- Parameters:
leftType
- The type of the left parameterrightType
- The type of the right parameteroperator
- The name of the operator (e.g. "+").- Returns:
- The type of the result
- Throws:
StandardException
- Thrown on error
-
convertible
Determine if this type can be CONVERTed to some other type- Parameters:
otherType
- The CompilationType of the other type to compare this type toforDataTypeFunction
- 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:
- true if the types can be converted, false if conversion is not allowed
-
compatible
Determine if this type is compatible to some other type (e.g. COALESCE(thistype, othertype)).- Parameters:
otherType
- The CompilationType of the other type to compare this type to- Returns:
- true if the types are compatible, false if not compatible
-
storable
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
- The TypeId of the other type to compare this type tocf
- A ClassFactory- Returns:
- true if the other type can be stored in a column of this type.
-
interfaceName
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:
- The name of the interface for this type.
-
getCorrespondingPrimitiveTypeName
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:
- The name of the corresponding Java primitive type.
-
getPrimitiveMethodName
String getPrimitiveMethodName()Get the method name for getting out the corresponding primitive Java type from a DataValueDescriptor.- Returns:
- String The method call name for getting the corresponding primitive Java type.
-
generateNull
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
- The method to put the expression incollationType
- 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.
-
generateDataValue
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
- The method to put the expression incollationType
- 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
-
getCastToCharWidth
Return the maximum width for this data type when cast to a char type.- Parameters:
dts
- The associated DataTypeDescriptor for this TypeId.- Returns:
- int The maximum width for this data type when cast to a char type.
-