saffron.ext
Class ReflectSchema

java.lang.Object
  |
  +--saffron.ext.ReflectSchema
All Implemented Interfaces:
Schema

public class ReflectSchema
extends Object
implements Schema

ReflectSchema uses reflection to find definitions of tables. Every public member (field or method) which implements Table can be used as a relation. For example,

class SalesSchema extends ReflectSchema {
   public Table emps = JdbcTable(this, "EMP");
   public Table depts = JdbcTable(this, "DEPT");
 }

 class SalesConnection extends Connection {
   public static Schema getSchema() {
     return new Sales();
 }

 SalesConnection sales;
 Emp[] femaleEmps = (select from sales.emps as emp where emp.gender.equals("F"));
 
allows you to write expressions like select from

Since:
10 November, 2001
Version:
$Id: //open/saffron/src/main/saffron/ext/ReflectSchema.java#5 $
Author:
jhyde

Field Summary
private  Object target
           
 TypeFactoryImpl typeFactory
           
 
Constructor Summary
ReflectSchema()
          Creates a schema whose 'tables' are its own public fields.
ReflectSchema(Object target)
          Creates a schema whose 'tables' are the public fields in a given object.
 
Method Summary
 Table getTableForMember(String name)
          Retrieves a Table based upon a member access.
 Table getTableForMethodCall(MethodCall call)
          Retrieves a Table based upon a method call (for example, salesSchema.empsInDept("SALES")).
 TypeFactory getTypeFactory()
          Returns the type factory used to generate types for this schema.
 void registerRules(Planner planner)
          Registers all of the rules supported by this schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

target

private final Object target

typeFactory

public final TypeFactoryImpl typeFactory
Constructor Detail

ReflectSchema

public ReflectSchema(Object target)
Creates a schema whose 'tables' are the public fields in a given object.


ReflectSchema

public ReflectSchema()
Creates a schema whose 'tables' are its own public fields.

Method Detail

getTableForMember

public Table getTableForMember(String name)
Description copied from interface: Schema
Retrieves a Table based upon a member access.

For example, the Saffron expression salesSchema.emps would be resolved using a call to salesSchema.getTableForMember(typeFactory, "emps").

Specified by:
getTableForMember in interface Schema

getTableForMethodCall

public Table getTableForMethodCall(MethodCall call)
Description copied from interface: Schema
Retrieves a Table based upon a method call (for example, salesSchema.empsInDept("SALES")).

Specified by:
getTableForMethodCall in interface Schema

registerRules

public void registerRules(Planner planner)
                   throws Exception
Description copied from interface: Schema
Registers all of the rules supported by this schema. Only called by Planner.registerSchema(saffron.Schema).

Specified by:
registerRules in interface Schema
Exception

getTypeFactory

public TypeFactory getTypeFactory()
Description copied from interface: Schema
Returns the type factory used to generate types for this schema.

Specified by:
getTypeFactory in interface Schema

SourceForge.net_Logo