net.sf.saffron.ext
Class ReflectSchema

java.lang.Object
  |
  +--net.sf.saffron.ext.ReflectSchema
All Implemented Interfaces:
SaffronSchema

public class ReflectSchema
extends Object
implements SaffronSchema

Schema which uses reflection to find definitions of tables.

Every public member (field or method) which implements SaffronTable can be used as a relation. Consider the following:

class SalesSchema extends ReflectSchema {
     public SaffronTable emps = JdbcTable(this, "EMP");
     public SaffronTable depts = JdbcTable(this, "DEPT");
 }
 class SalesConnection extends SaffronConnection {
     public static SaffronSchema getSaffronSchema() {
         return new SalesSchema();
     }
 }
 SalesConnection sales;
 Emp[] femaleEmps = (select from sales.emps as emp where emp.gender.equals("F"));
 
The expression sales.emps is a valid table because (a) sales is a SaffronConnection, (b) its static method getSaffronSchema() returns a ReflectSchema, and (c) ReflectSchema has a public field emps of type SaffronTable.

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

Field Summary
private  Object target
           
 SaffronTypeFactoryImpl 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
 SaffronTable getTableForMember(String[] names)
          Retrieves a SaffronTable based upon a member access.
 SaffronTypeFactory getTypeFactory()
          Returns the type factory used to generate types for this schema.
 void registerRules(SaffronPlanner 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

typeFactory

public final SaffronTypeFactoryImpl typeFactory

target

private final Object target
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 SaffronTable getTableForMember(String[] names)
Description copied from interface: SaffronSchema
Retrieves a SaffronTable based upon a member access.

For example, the Saffron expression salesSchema.emps would be resolved using a call to salesSchema.getTableForMember(new String[]{"emps"}).

Note that name.length is only greater than 1 for queries originating from JDBC.

Specified by:
getTableForMember in interface SaffronSchema

getTypeFactory

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

Specified by:
getTypeFactory in interface SaffronSchema

registerRules

public void registerRules(SaffronPlanner planner)
                   throws Exception
Description copied from interface: SaffronSchema
Registers all of the rules supported by this schema. Only called by SaffronPlanner.registerSchema(net.sf.saffron.core.SaffronSchema).

Specified by:
registerRules in interface SaffronSchema
Exception

SourceForge.net_Logo