metagloss 0.0.2

net.sf.metagloss.db
Class AssistCursor<T extends java.lang.Enum<T> & ITable>

java.lang.Object
  extended by net.sf.metagloss.db.AssistCursor<T>
Type Parameters:
T - The table to work on.
All Implemented Interfaces:
Injector

public class AssistCursor<T extends java.lang.Enum<T> & ITable>
extends java.lang.Object
implements Injector

A partial wrapper for the Cursor class, offering annotation-based setter injection and automatic translation of column ids for SQL SELECT queries. Additionally provides convenience methods for retrieving relevant data from the supplied Cursor object.

The class is designed to only work on queries made on single tables.

See Also:
CursorBind, ITable

Constructor Summary
AssistCursor(java.lang.Class<T> table, android.database.Cursor cursor)
          Creates a new AssistCursor.
 
Method Summary
 double getDouble(T column)
           
 float getFloat(T column)
           
 int getInt(T column)
           
 long getLong(T column)
           
 java.lang.String getString(T column)
           
 void inject(java.lang.Object data)
          Injects the setters of the object to which the cursor relates.
 boolean next()
          Moves to the next row in the result set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssistCursor

public AssistCursor(java.lang.Class<T> table,
                    android.database.Cursor cursor)
Creates a new AssistCursor. The database columns are matched against the column layout within the Cursor object upon instantiation.

Parameters:
table - The database table to work on.
cursor - Cursor associated with a query on the supplied table.
Method Detail

getDouble

public double getDouble(T column)

getFloat

public float getFloat(T column)

getInt

public int getInt(T column)

getLong

public long getLong(T column)

getString

public java.lang.String getString(T column)

inject

public void inject(java.lang.Object data)
Injects the setters of the object to which the cursor relates. It is possible to inject several objects of different classes with subsequent calls, as long as they are properly annotated.

In order to make a setter eligible for injection, it must satisfy the following requirements:

  1. Field or Method annotated with CursorBind
  2. Public visibility on setter
  3. Single parameter argument
  4. Prefixed with set.

Note:

Even if the desired field is annotated with CursorBind, the appropriate setter method is still required.

Specified by:
inject in interface Injector
Parameters:
data - Object to be injected.

next

public boolean next()
Moves to the next row in the result set. Will throw an InjectionException if any subsequent calls are made this this method after returning false.

Specified by:
next in interface Injector
Returns:
True if the move was within the result set range.