saffron.rel
Class TypeFactoryImpl

java.lang.Object
  |
  +--saffron.rel.TypeFactoryImpl
All Implemented Interfaces:
TypeFactory
Direct Known Subclasses:
OJTypeFactoryImpl

public class TypeFactoryImpl
extends Object
implements TypeFactory

Implementation of TypeFactory.

Since:
May 31, 2003
Version:
$Id: //open/saffron/src/main/saffron/rel/TypeFactoryImpl.java#4 $
Author:
jhyde

Nested Class Summary
protected  class TypeFactoryImpl.CrossType
          Type of the cartesian product of two or more sets of records.
protected static class TypeFactoryImpl.FieldImpl
          Simple implementation of Field
protected  class TypeFactoryImpl.RecordType
          Type which is a set of named fields.
protected  class TypeFactoryImpl.ScalarType
          Type which is based upon a Java class.
protected  class TypeFactoryImpl.TypeImpl
          Abstract implementation for Type.
 
Nested classes inherited from class saffron.rel.TypeFactory
TypeFactory.FieldInfo
 
Field Summary
private  HashMap map
           
private static ThreadLocal threadInstances
           
 
Constructor Summary
TypeFactoryImpl()
           
 
Method Summary
private static void addFields(Type type, ArrayList fieldList)
          Adds all fields in type to fieldList.
protected  Type canonize(Type type)
          Registers a type, or returns the existing type if it is already registered.
 Type createJavaType(Class clazz)
          Creates a type which encapsulates a Java class.
 Type createJoinType(Type[] types)
          Creates a cartesian product type.
 Type createProjectType(Type[] types, String[] fieldNames)
          Creates a type which represents a projection of a set of fields.
 Type createProjectType(TypeFactory.FieldInfo fieldInfo)
          Creates a type which represents a projection of a set fields, getting the field informatation from a callback.
private static Field[] getFieldArray(Type[] types)
          Returns an array of the fields in an array of types.
private static Type[] getTypeArray(Type[] types)
          Returns an array of all atomic types in an array.
private static void getTypeArray(Type[] types, ArrayList typeList)
           
 Type leastRestrictive(Type[] 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.
static void setThreadInstance(TypeFactory typeFactory)
           
static TypeFactory threadInstance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

private HashMap map

threadInstances

private static ThreadLocal threadInstances
Constructor Detail

TypeFactoryImpl

public TypeFactoryImpl()
Method Detail

createProjectType

public Type createProjectType(Type[] types,
                              String[] fieldNames)
Description copied from interface: TypeFactory
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.

Specified by:
createProjectType in interface TypeFactory
Parameters:
types - Types of the fields
fieldNames - Names of the fields
Returns:
a type

createProjectType

public Type createProjectType(TypeFactory.FieldInfo fieldInfo)
Description copied from interface: TypeFactory
Creates a type which represents a projection of a set fields, getting the field informatation from a callback.

Specified by:
createProjectType in interface TypeFactory

createJoinType

public Type createJoinType(Type[] types)
Description copied from interface: TypeFactory
Creates a cartesian product type.

Specified by:
createJoinType in interface TypeFactory

createJavaType

public Type createJavaType(Class clazz)
Description copied from interface: TypeFactory
Creates a type which encapsulates a Java class.

Specified by:
createJavaType in interface TypeFactory

leastRestrictive

public Type leastRestrictive(Type[] types)
Description copied from interface: TypeFactory
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.

Specified by:
leastRestrictive in interface TypeFactory

canonize

protected Type canonize(Type type)
Registers a type, or returns the existing type if it is already registered.


getTypeArray

private static Type[] getTypeArray(Type[] types)
Returns an array of all atomic types in an array.


getTypeArray

private static void getTypeArray(Type[] types,
                                 ArrayList typeList)

getFieldArray

private static Field[] getFieldArray(Type[] types)
Returns an array of the fields in an array of types.


addFields

private static void addFields(Type type,
                              ArrayList fieldList)
Adds all fields in type to fieldList.


setThreadInstance

public static void setThreadInstance(TypeFactory typeFactory)

threadInstance

public static TypeFactory threadInstance()

SourceForge.net_Logo