net.sf.saffron.core
Interface SaffronTypeFactory

All Known Subinterfaces:
OJTypeFactory
All Known Implementing Classes:
OJTypeFactoryImpl, SaffronTypeFactoryImpl

public interface SaffronTypeFactory

Creates types.

Any implementation of SaffronTypeFactory must ensure that types are canonical: two types are equal if and only if they are the same object.

Since:
May 29, 2003
Version:
$Id: //open/saffron/src/net/sf/saffron/core/SaffronTypeFactory.java#4 $
Author:
jhyde

Nested Class Summary
static interface SaffronTypeFactory.FieldInfo
          Callback which provides enough information to create fields.
 
Method Summary
 SaffronType createJavaType(Class clazz)
          Creates a type which encapsulates a Java class.
 SaffronType createJoinType(SaffronType[] types)
          Creates a cartesian product type.
 SaffronType createProjectType(SaffronType[] types, String[] fieldNames)
          Creates a type which represents a projection of a set of fields.
 SaffronType createProjectType(SaffronTypeFactory.FieldInfo fieldInfo)
          Creates a type which represents a projection of a set fields, getting the field informatation from a callback.
 SaffronTypeFactoryImpl.SqlType createSqlType(SqlTypeName typeName)
          Creates a SQL type with no precision or scale.
 SaffronTypeFactoryImpl.SqlType createSqlType(SqlTypeName typeName, int length)
          Creates a SQL type with length (precision) but no scale.
 SaffronTypeFactoryImpl.SqlType createSqlType(SqlTypeName typeName, int length, int scale)
          Creates a SQL type with length (precision) and scale.
 SaffronType createTypeWithNullability(SaffronType type, boolean nullable)
          Creates a Type which is the same as another type but with possibily different nullability.
 SaffronType leastRestrictive(SaffronType[] types)
          Returns the most general of a set of types (that is, one type to which they can all be cast), or null if conversion is not possible.
 

Method Detail

createJavaType

public SaffronType createJavaType(Class clazz)
Creates a type which encapsulates a Java class.


createJoinType

public SaffronType createJoinType(SaffronType[] types)
Creates a cartesian product type.

Pre-condition:
types != null, types.length >= 1

createProjectType

public SaffronType createProjectType(SaffronType[] types,
                                     String[] fieldNames)
Creates a type which represents a projection of a set of fields.

The return is canonical: if an equivalent type already exists, it is returned.

Parameters:
types - Types of the fields
fieldNames - Names of the fields
Returns:
a type
Pre-condition:
types.length == fieldNames.length
Post-condition:
return != null

createProjectType

public SaffronType createProjectType(SaffronTypeFactory.FieldInfo fieldInfo)
Creates a type which represents a projection of a set fields, getting the field informatation from a callback.


createTypeWithNullability

public SaffronType createTypeWithNullability(SaffronType type,
                                             boolean nullable)
Creates a Type which is the same as another type but with possibily different nullability. For type systems without a concept of nullability, the return value is always the same as the input.

Parameters:
type - input type
nullable - true to request a nullable type; false to request a NOT NULL type
Returns:
output type, same as input type except with specified nullability

leastRestrictive

public SaffronType leastRestrictive(SaffronType[] types)
Returns the most general of a set of types (that is, one type to which they can all be cast), or null if conversion is not possible.

Pre-condition:
types != null, types.length >= 1

createSqlType

public SaffronTypeFactoryImpl.SqlType createSqlType(SqlTypeName typeName)
Creates a SQL type with no precision or scale.

Parameters:
typeName - Name of the type, for example SqlTypeName.Boolean.
Returns:
A type
Pre-condition:
typeName != null
Post-condition:
return != null

createSqlType

public SaffronTypeFactoryImpl.SqlType createSqlType(SqlTypeName typeName,
                                                    int length)
Creates a SQL type with length (precision) but no scale.

Parameters:
typeName - Name of the type, for example SqlTypeName.Varchar.
length - Maximum length of the value (non-numeric types) or the precision of the value (numeric types)
Returns:
A type
Pre-condition:
typeName != null, length >= 0
Post-condition:
return != null

createSqlType

public SaffronTypeFactoryImpl.SqlType createSqlType(SqlTypeName typeName,
                                                    int length,
                                                    int scale)
Creates a SQL type with length (precision) and scale.

Parameters:
typeName - Name of the type, for example SqlTypeName.Varchar.
length - Maximum length of the value (non-numeric types) or the precision of the value (numeric types)
scale - Scale of the values. 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.
Returns:
A type
Pre-condition:
typeName != null, length >= 0
Post-condition:
return != null

SourceForge.net_Logo