com.google.providerhelper
Class Reader<T extends Builder>

java.lang.Object
  extended by com.google.providerhelper.Reader<T>
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Iterator<T>

public class Reader<T extends Builder>
extends java.lang.Object
implements java.util.Iterator<T>, java.lang.Iterable<T>

Provides a java-style iterator over objects retrieved from rows of an Android ContentProvider; the objects' class must extend Builder.

Here is an example of the use of this class to process Call objects which represent entries in the phone-call log, assuming that Call extends Builder.

 Reader<Call> calls = new Reader<Call>(Call.class, activity,
         CallLog.Calls.CONTENT_URI);
 for (Call call : calls) {
     // do something with call
 }
 

See Also:
Builder

Constructor Summary
Reader(java.lang.Class<T> rowClass, Activity a, Uri u)
          Creates a reader given a class to load, an Activity, and a Content-Provider Uri.
Reader(java.lang.Class<T> rowClass, Cursor cursor)
          Creates a reader given a class to load and a Cursor to read from.
 
Method Summary
 boolean hasNext()
           
 java.util.Iterator<T> iterator()
           
 T next()
           
 void remove()
          Not implemented.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Reader

public Reader(java.lang.Class<T> rowClass,
              Activity a,
              Uri u)
Creates a reader given a class to load, an Activity, and a Content-Provider Uri.

Parameters:
row - The class of the object which is to be loaded. Must extend Builder.
a - The current activity.
u - The Uri which identifies the Content Provider to load from.

Reader

public Reader(java.lang.Class<T> rowClass,
              Cursor cursor)
Creates a reader given a class to load and a Cursor to read from.

Parameters:
The - class of the object which is to be loaded. Must extend Builder.
The - android.database.Cursor to read from.
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<T extends Builder>

next

public T next()
Specified by:
next in interface java.util.Iterator<T extends Builder>

remove

public void remove()
Not implemented.

Specified by:
remove in interface java.util.Iterator<T extends Builder>

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T extends Builder>