|
![]() |
||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
ITable | An interface for DB tables represented as enum classes. |
QueryProvider | Marker interface for queries. |
Class Summary | |
---|---|
AssistCursor<T extends Enum<T> & ITable> | A partial wrapper for the Cursor class, offering annotation-based setter injection
and automatic translation of column ids for SQL SELECT queries. |
DBUtils | Utility class for working with databases and building ContentValues from
classes annotated with CursorBind . |
QueryManager | Utility class for retrieving the implementation of a QueryProvider interface. |
Exception Summary | |
---|---|
QueryImplementationException | Exception is thrown if the QueryManager#getImplementation(Class) is unable
to allocate the implementation. |
Annotation Types Summary | |
---|---|
CursorBind | Annotation to mark setter for data injection from a Cursor object and
getters to ContentValues . |
Query | Annotation specifies an SQL query. |
TableName | Annotation type to set the DB table name for any ITable implementations. |
Provides classes for working with databases.
In order to make use of the database classes, relevant tables in the database
should be implemented as an enum class extending ITable
- the class itself must have the TableName
annotation.
TheEnum table class (from BOINC Echo)
@TableName("be_user_host") public enum UserHostTable implements ITable { Id("id"), UserTableId("user_id"), CPID("cpid"), Name("name"), HostId("host_id"), CreatedOn("created_on"), Credit("credit"), RAC("rac"), CPUCount("cpu_count"), FLOPS("float_ops"), MIPS("int_ops"), Vendor("vendor"), Model("model"), OS("os_name"); private final String name; private UserHostTable(String column) { this.name = column; } @Override public String getColumn() { return this.name; } }
CursorBind
annotation configures data objects
to be eligible for setter injection from database sources and
translation
into ContentValues
.
The AssistCursor
wraps around the Cursor
class, adding setter
injection and resolving columns to positions in the result set.
Table data is accessed by passing the appropriate enums of ITable
enum classes.
Injecting objects annotated with CursorBind
is as simple as:
List<Host> hosts = new ArrayList<Hosts>(); Cursor cursor = ...; AssistCursor<UserHostTable> ac = new AssistCursor<UserHostTable>(UserHostTable.class, cursor); while (ac.next()) { Host host = new Host(); ac.inject(host); hosts.add(host); } cursor.close(); // etc
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |