If you think the Android project DKO listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.kered.dko;
//fromwww.java2s.comimport javax.sql.DataSource;
/**
* This is a relatively uninteresting factory class that you will likely
* never use. Please look at the generated <code>TableName.ALL</code> objects
* for starting your queries. (DataSources can be specified with
* <code>TableName.ALL.use(ds)</code>)
* @author dander
*
*/publicclass QueryFactory {
protected QueryFactory() {}
/**
* singleton instance
*/publicstaticfinal QueryFactory IT = new QueryFactory();
/**
* Creates a query centered around the given class.
* @param cls
* @return
*/public <T extends Table> Query<T> getQuery(final Class<T> cls) {
returnnew DBQuery<T>(cls);
}
/**
* Creates a query centered around the given class using the given datasource.
* @param cls
* @param ds
* @return
*/public <T extends Table> Query<T> getQuery(final Class<T> cls, final DataSource ds) {
returnnew DBQuery<T>(cls, ds);
}
/**
* Creates a new query based the given query, but adds a constant field to the resulting list of tables.
* @param cls
* @return
*/public <S, T extends Table> Query<Table> addField(final Query<T> q, final Field<S> field, final S value) {
returnnew QueryAddField(q, field, value);
}
/**
* Creates a new query based the given query, but adds a function-defined field to the resulting list of tables.
* @param cls
* @return
*/public <S, T extends Table> Query<Table> addFieldFromCallback(final Query<T> q, final Field<S> field, final Callback<Table,S> func) {
returnnew QueryAddField(q, field, func);
}
publicstaticinterface Callback<A,B> {
public B apply(A a);
}
}