|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.saffron.ext.ReflectSchema
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:
The expressionclass SalesSchema extendsReflectSchema
{ publicSaffronTable
emps =JdbcTable
(this, "EMP"); publicSaffronTable
depts =JdbcTable
(this, "DEPT"); } class SalesConnection extendsSaffronConnection
{ public staticSaffronSchema
getSaffronSchema() { return new SalesSchema(); } } SalesConnection sales; Emp[] femaleEmps = (select from sales.emps as emp where emp.gender.equals("F"));
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
.
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 |
public final SaffronTypeFactoryImpl typeFactory
private final Object target
Constructor Detail |
public ReflectSchema(Object target)
public ReflectSchema()
Method Detail |
public SaffronTable getTableForMember(String[] names)
SaffronSchema
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.
getTableForMember
in interface SaffronSchema
public SaffronTypeFactory getTypeFactory()
SaffronSchema
type factory
used to generate
types for this schema.
getTypeFactory
in interface SaffronSchema
public void registerRules(SaffronPlanner planner) throws Exception
SaffronSchema
SaffronPlanner.registerSchema(net.sf.saffron.core.SaffronSchema)
.
registerRules
in interface SaffronSchema
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |