com.akiban.sql.compiler
Class DateTypeCompiler

java.lang.Object
  extended by com.akiban.sql.compiler.TypeCompiler
      extended by com.akiban.sql.compiler.DateTypeCompiler

public class DateTypeCompiler
extends TypeCompiler


Field Summary
 
Fields inherited from class com.akiban.sql.compiler.TypeCompiler
AVG_OP, BOOLEAN_MAXWIDTH_AS_CHAR, DIV_OP, DIVIDE_OP, DOUBLE_MAXWIDTH_AS_CHAR, INT_MAXWIDTH_AS_CHAR, LONGINT_MAXWIDTH_AS_CHAR, MINUS_OP, MOD_OP, PLUS_OP, REAL_MAXWIDTH_AS_CHAR, SMALLINT_MAXWIDTH_AS_CHAR, SUM_OP, TIMES_OP, TINYINT_MAXWIDTH_AS_CHAR
 
Constructor Summary
protected DateTypeCompiler(TypeId typeId)
           
 
Method Summary
 boolean compatible(TypeId otherType)
          Tell whether this type (date) is compatible with the given type.
 boolean convertible(TypeId otherType, boolean forDataTypeFunction)
          User types are convertible to other user types only if (for now) they are the same type and are being used to implement some JDBC type.
 int getCastToCharWidth(DataTypeDescriptor dts)
          Return the maximum width for this data type when cast to a char type.
 String getCorrespondingPrimitiveTypeName()
          Get the name of the corresponding Java type.
 String getPrimitiveMethodName()
          Get the method name for getting out the corresponding primitive Java type.
 DataTypeDescriptor resolveArithmeticOperation(DataTypeDescriptor leftType, DataTypeDescriptor rightType, String operator)
          Type resolution methods on binary operators
 
Methods inherited from class com.akiban.sql.compiler.TypeCompiler
getStoredFormatIdFromTypeId, getTypeCompiler, getTypeId, numberConvertible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateTypeCompiler

protected DateTypeCompiler(TypeId typeId)
Method Detail

convertible

public boolean convertible(TypeId otherType,
                           boolean forDataTypeFunction)
User types are convertible to other user types only if (for now) they are the same type and are being used to implement some JDBC type. This is sufficient for date/time types; it may be generalized later for e.g. comparison of any user type with one of its subtypes.

Specified by:
convertible in class TypeCompiler
Parameters:
otherType - The CompilationType of the other type to compare this type to
forDataTypeFunction - 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
See Also:
TypeCompiler.convertible(com.akiban.sql.types.TypeId, boolean)

compatible

public boolean compatible(TypeId otherType)
Tell whether this type (date) is compatible with the given type.

Specified by:
compatible in class TypeCompiler
Parameters:
otherType - The TypeId of the other type.
Returns:
true if the types are compatible, false if not compatible

getCorrespondingPrimitiveTypeName

public String getCorrespondingPrimitiveTypeName()
Description copied from class: TypeCompiler
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.

Specified by:
getCorrespondingPrimitiveTypeName in class TypeCompiler
Returns:
The name of the corresponding Java primitive type.
See Also:
TypeCompiler.getCorrespondingPrimitiveTypeName()

getPrimitiveMethodName

public String getPrimitiveMethodName()
Get the method name for getting out the corresponding primitive Java type.

Specified by:
getPrimitiveMethodName in class TypeCompiler
Returns:
String The method call name for getting the corresponding primitive Java type.

getCastToCharWidth

public int getCastToCharWidth(DataTypeDescriptor dts)
Description copied from class: TypeCompiler
Return the maximum width for this data type when cast to a char type.

Specified by:
getCastToCharWidth in class TypeCompiler
Parameters:
dts - The associated DataTypeDescriptor for this TypeId.
Returns:
int The maximum width for this data type when cast to a char type.
See Also:
TypeCompiler.getCastToCharWidth(com.akiban.sql.types.DataTypeDescriptor)

resolveArithmeticOperation

public DataTypeDescriptor resolveArithmeticOperation(DataTypeDescriptor leftType,
                                                     DataTypeDescriptor rightType,
                                                     String operator)
                                              throws StandardException
Description copied from class: TypeCompiler
Type resolution methods on binary operators

Overrides:
resolveArithmeticOperation in class TypeCompiler
Parameters:
leftType - The type of the left parameter
rightType - The type of the right parameter
operator - The name of the operator (e.g. "+").
Returns:
The type of the result
Throws:
StandardException - Thrown on error
See Also:
TypeCompiler.resolveArithmeticOperation(com.akiban.sql.types.DataTypeDescriptor, com.akiban.sql.types.DataTypeDescriptor, java.lang.String)


Copyright © 2013 Akiban Technologies, Inc. All rights reserved.