|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.reltype.RelDataTypeFactoryImpl org.eigenbase.sql.type.SqlTypeFactoryImpl org.eigenbase.oj.OJTypeFactoryImpl net.sf.farrago.type.FarragoTypeFactoryImpl
public class FarragoTypeFactoryImpl
FarragoTypeFactoryImpl is the Farrago-specific implementation of the RelDataTypeFactory interface.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.eigenbase.reltype.RelDataTypeFactoryImpl |
---|
RelDataTypeFactoryImpl.JavaType |
Nested classes/interfaces inherited from interface org.eigenbase.reltype.RelDataTypeFactory |
---|
RelDataTypeFactory.FieldInfo, RelDataTypeFactory.ListFieldInfo |
Field Summary | |
---|---|
private Map<RelDataType,OJClass> |
mapTypeToOJClass
|
private int |
nextGeneratedClassId
|
private FarragoRepos |
repos
Repos for type object definitions. |
private static int |
unknownCharPrecision
|
Fields inherited from class org.eigenbase.oj.OJTypeFactoryImpl |
---|
mapOJClassToType |
Constructor Summary | |
---|---|
FarragoTypeFactoryImpl(FarragoRepos repos)
|
Method Summary | |
---|---|
private RelDataType |
addDefaultAttributes(RelDataType type)
|
RelDataType |
createCwmElementType(FemAbstractTypedElement abstractElement)
Creates a type which represents the datatype of a FemAbstractTypedElement. |
RelDataType |
createCwmType(CwmSqldataType cwmType)
Creates a type which represents a CwmSqldataType. |
protected RelDataType |
createCwmTypeImpl(CwmClassifier classifier,
FemSqltypedElement element)
|
RelDataType |
createJavaType(Class clazz)
Creates a type which corresponds to a Java class. |
RelDataType |
createJdbcColumnType(ResultSet getColumnsResultSet,
boolean substitute)
Creates a type which represents column metadata returned by the DatabaseMetaData.getColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String) call. |
RelDataType |
createJdbcColumnType(ResultSet getColumnsResultSet,
boolean substitute,
Properties typeMapping)
Creates a type which represents column metadata returned by the DatabaseMetaData.getColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String) call. |
private RelDataType |
createJdbcType(int typeOrdinal,
String dbSpecTypeName,
int precision,
int scale,
boolean isNullable,
boolean substitute,
Properties typeMapping)
|
RelDataType |
createJoinType(RelDataType[] types)
Creates a cartesian product type. |
RelDataType |
createMofType(StructuralFeature feature)
Creates a type which represents a MOF feature. |
RelDataType |
createResultSetType(ResultSetMetaData metaData,
boolean substitute)
Creates a type which represents the row datatype of a JDBC ResultSet. |
RelDataType |
createResultSetType(ResultSetMetaData metaData,
boolean substitute,
Properties typeMapping)
Creates a type which represents the row datatype of a JDBC ResultSet. |
RelDataType |
createSqlType(SqlTypeName typeName)
Creates a SQL type with no precision or scale. |
RelDataType |
createSqlType(SqlTypeName typeName,
int precision)
Creates a SQL type with length (precision) but no scale. |
RelDataType |
createSqlType(SqlTypeName typeName,
int precision,
int scale)
Creates a SQL type with precision and scale. |
RelDataType |
createStructTypeFromClassifier(CwmClassifier classifier)
Creates a type which represents a structured row based on a classifier definition from the catalog. |
private String |
extractDataTypeName(String mapping)
|
private int |
extractPrecision(String mapping,
int precision)
|
private int |
extractScale(String mapping,
int scale)
|
(package private) int |
generateClassId()
|
private MethodDeclaration |
generateGetter(TypeName returnType,
String methodName,
Expression value)
Generates a protected getter method |
Class |
getClassForJavaParamStyle(RelDataType type)
Looks up the Class specified by the JAVA parameter
style for user-defined routines. |
Class |
getClassForPrimitive(RelDataType type)
Looks up the Class representing a primitive used to
hold a value of the given type. |
Charset |
getDefaultCharset()
|
private int[] |
getMappedDataType(int ordinal,
int precision,
int scale,
String dbSpecTypeName,
Properties typeMapping)
|
FarragoRepos |
getRepos()
|
private RelDataTypeComparability |
getUserDefinedComparability(FemUserDefinedType type)
|
Expression |
getValueAccessExpression(RelDataType type,
Expression expr)
Constructs an OpenJava expression to access a value of an atomic type. |
private boolean |
isKnownUnsupportedJdbcType(SqlTypeName type)
|
private Expression |
lookupTimeUnit(SqlIntervalQualifier.TimeUnit timeUnit)
Generates an expression for a SqlIntervalQualifier.TimeUnit . |
private OJClass |
newDatetimeOJClass(Class superclass,
OJClass declarer,
RelDataType type)
|
private OJClass |
newDecimalOJClass(OJClass declarer,
RelDataType type)
|
private OJClass |
newHolderOJClass(Class superclass,
MemberDeclarationList memberDecls,
OJClass declarer,
RelDataType type)
|
private OJClass |
newIntervalOJClass(Class superclass,
OJClass declarer,
RelDataType type)
|
private OJClass |
newOJClass(OJClass declarer,
RelDataType type)
|
private EigenbaseException |
newSqlTypeException(Throwable ex)
|
private OJClass |
newStringOJClass(OJClass declarer,
RelDataType type)
|
private EigenbaseException |
newUnsupportedJdbcType(String tableName,
String columnName,
String typeName,
int typeOrdinal,
int precision,
int scale,
Throwable ex)
|
OJClass |
toOJClass(OJClass declarer,
RelDataType type)
|
Methods inherited from class org.eigenbase.oj.OJTypeFactoryImpl |
---|
createArrayType, createOJClassForRecordType, toType |
Methods inherited from class org.eigenbase.sql.type.SqlTypeFactoryImpl |
---|
canonize, createMultisetType, createSqlIntervalType, createTypeWithCharsetAndCollation, createTypeWithNullability, leastRestrictive, shouldRaggedFixedLengthValueUnionBeVariable |
Methods inherited from class org.eigenbase.reltype.RelDataTypeFactoryImpl |
---|
copyType, createDecimalProduct, createDecimalQuotient, createStructType, createStructType, createStructType, isJavaType, leastRestrictiveStructuredType, useDoubleMultiplication |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eigenbase.oj.OJTypeFactory |
---|
toType |
Methods inherited from interface org.eigenbase.reltype.RelDataTypeFactory |
---|
copyType, createArrayType, createDecimalProduct, createDecimalQuotient, createMultisetType, createSqlIntervalType, createStructType, createStructType, createStructType, createTypeWithCharsetAndCollation, createTypeWithNullability, leastRestrictive, useDoubleMultiplication |
Field Detail |
---|
private static final int unknownCharPrecision
private final FarragoRepos repos
private int nextGeneratedClassId
private final Map<RelDataType,OJClass> mapTypeToOJClass
Constructor Detail |
---|
public FarragoTypeFactoryImpl(FarragoRepos repos)
Method Detail |
---|
public FarragoRepos getRepos()
getRepos
in interface FarragoTypeFactory
public RelDataType createJoinType(RelDataType[] types)
RelDataTypeFactory
createJoinType
in interface RelDataTypeFactory
createJoinType
in class RelDataTypeFactoryImpl
public RelDataType createCwmElementType(FemAbstractTypedElement abstractElement)
FarragoTypeFactory
createCwmElementType
in interface FarragoTypeFactory
abstractElement
- CWM typed element
public RelDataType createCwmType(CwmSqldataType cwmType)
FarragoTypeFactory
createCwmType
in interface FarragoTypeFactory
cwmType
- CWM type instance
protected RelDataType createCwmTypeImpl(CwmClassifier classifier, FemSqltypedElement element)
private RelDataTypeComparability getUserDefinedComparability(FemUserDefinedType type)
public RelDataType createStructTypeFromClassifier(CwmClassifier classifier)
FarragoTypeFactory
createStructTypeFromClassifier
in interface FarragoTypeFactory
classifier
- definition of classifier
public RelDataType createResultSetType(ResultSetMetaData metaData, boolean substitute)
FarragoTypeFactory
createResultSetType
in interface FarragoTypeFactory
metaData
- metadata for JDBC ResultSetsubstitute
- if true, use substitutions; if false, throw exception
for unsupported types or type attributes
public RelDataType createResultSetType(ResultSetMetaData metaData, boolean substitute, Properties typeMapping)
FarragoTypeFactory
createResultSetType
in interface FarragoTypeFactory
metaData
- metadata for JDBC ResultSetsubstitute
- if true, use substitutions; if false, throw exception
for unsupported types or type attributestypeMapping
- types to substitute
public RelDataType createJdbcColumnType(ResultSet getColumnsResultSet, boolean substitute)
FarragoTypeFactory
DatabaseMetaData.getColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
call. See FarragoTypeFactory.createResultSetType(java.sql.ResultSetMetaData, boolean)
for
details on type substitutions.
createJdbcColumnType
in interface FarragoTypeFactory
getColumnsResultSet
- ResultSet
positioned on a row
returned from the getColumns call; result set position is unchanged by
this methodsubstitute
- if true, use substitutions; if false, throw exception
for unsupported types or type attributes
public RelDataType createJdbcColumnType(ResultSet getColumnsResultSet, boolean substitute, Properties typeMapping)
FarragoTypeFactory
DatabaseMetaData.getColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
call. See FarragoTypeFactory.createResultSetType(java.sql.ResultSetMetaData, boolean)
for
details on type substitutions.
createJdbcColumnType
in interface FarragoTypeFactory
getColumnsResultSet
- ResultSet
positioned on a row
returned from the getColumns call; result set position is unchanged by
this methodsubstitute
- if true, use substitutions; if false, throw exception
for unsupported types or type attributestypeMapping
- types to substitute
private RelDataType createJdbcType(int typeOrdinal, String dbSpecTypeName, int precision, int scale, boolean isNullable, boolean substitute, Properties typeMapping) throws Throwable
Throwable
private EigenbaseException newSqlTypeException(Throwable ex)
private EigenbaseException newUnsupportedJdbcType(String tableName, String columnName, String typeName, int typeOrdinal, int precision, int scale, Throwable ex)
int generateClassId()
public RelDataType createMofType(StructuralFeature feature)
FarragoTypeFactory
createMofType
in interface FarragoTypeFactory
feature
- MOF feature
public OJClass toOJClass(OJClass declarer, RelDataType type)
toOJClass
in interface OJTypeFactory
toOJClass
in class OJTypeFactoryImpl
private OJClass newOJClass(OJClass declarer, RelDataType type)
private OJClass newDecimalOJClass(OJClass declarer, RelDataType type)
private OJClass newDatetimeOJClass(Class superclass, OJClass declarer, RelDataType type)
private OJClass newIntervalOJClass(Class superclass, OJClass declarer, RelDataType type)
private Expression lookupTimeUnit(SqlIntervalQualifier.TimeUnit timeUnit)
SqlIntervalQualifier.TimeUnit
.
timeUnit
- Time unit
private OJClass newStringOJClass(OJClass declarer, RelDataType type)
private OJClass newHolderOJClass(Class superclass, MemberDeclarationList memberDecls, OJClass declarer, RelDataType type)
private MethodDeclaration generateGetter(TypeName returnType, String methodName, Expression value)
returnType
- type of value returned by the getter methodmethodName
- the name of the getter methodvalue
- the value to be returned by the getter method
public Expression getValueAccessExpression(RelDataType type, Expression expr)
FarragoTypeFactory
getValueAccessExpression
in interface FarragoTypeFactory
type
- atomic typeexpr
- expression representing site to be accessed
public Class getClassForPrimitive(RelDataType type)
FarragoTypeFactory
Class
representing a primitive used to
hold a value of the given type.
getClassForPrimitive
in interface FarragoTypeFactory
type
- value type
public Class getClassForJavaParamStyle(RelDataType type)
FarragoTypeFactory
Class
specified by the JAVA parameter
style for user-defined routines.
getClassForJavaParamStyle
in interface FarragoTypeFactory
type
- SQL type
public RelDataType createJavaType(Class clazz)
RelDataTypeFactory
createJavaType
in interface RelDataTypeFactory
createJavaType
in class OJTypeFactoryImpl
clazz
- the Java class used to define the type
public RelDataType createSqlType(SqlTypeName typeName)
RelDataTypeFactory
createSqlType
in interface RelDataTypeFactory
createSqlType
in class SqlTypeFactoryImpl
typeName
- Name of the type, for example SqlTypeName.BOOLEAN
.
public RelDataType createSqlType(SqlTypeName typeName, int precision)
RelDataTypeFactory
createSqlType
in interface RelDataTypeFactory
createSqlType
in class SqlTypeFactoryImpl
typeName
- Name of the type, for example SqlTypeName.VARCHAR
.precision
- maximum length of the value (non-numeric types) or the
precision of the value (numeric/datetime types) requires both operands to
have exact numeric types.
public RelDataType createSqlType(SqlTypeName typeName, int precision, int scale)
RelDataTypeFactory
createSqlType
in interface RelDataTypeFactory
createSqlType
in class SqlTypeFactoryImpl
typeName
- Name of the type, for example SqlTypeName.DECIMAL
.precision
- precision of the valuescale
- scale of the values, i.e. the number of decimal places to
shift the value. For example, a NUMBER(10,3) value of "123.45" is
represented "123450" (that is, multiplied by 10^3). A negative scale
is valid.
private RelDataType addDefaultAttributes(RelDataType type)
public Charset getDefaultCharset()
getDefaultCharset
in interface RelDataTypeFactory
getDefaultCharset
in class RelDataTypeFactoryImpl
Charset
for string typesprivate int[] getMappedDataType(int ordinal, int precision, int scale, String dbSpecTypeName, Properties typeMapping)
private String extractDataTypeName(String mapping)
private int extractPrecision(String mapping, int precision)
private int extractScale(String mapping, int scale)
private boolean isKnownUnsupportedJdbcType(SqlTypeName type)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |