|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
org.hermit.android.net.WebBasedData
public class WebBasedData
This class implements a web-based source of data, which is cached in a local database. The data is assumed to be timestamped records.
Constructor Summary | |
---|---|
WebBasedData(java.lang.String name,
java.lang.String base,
java.lang.String suff,
long interval,
boolean ldate,
java.lang.String[] fields)
Create a web-based data source. |
Method Summary | |
---|---|
Cursor |
allRecords()
Query for all records we have stored. |
Cursor |
allRecordsSince(long date)
Query for all records we have stored timstamped AFTER a given date. |
void |
createTable(SQLiteDatabase db)
Create our table in the database. |
java.lang.String |
getName()
Get the name of this source. |
ContentValues |
lastRecord()
Query for the newest record we have stored. |
void |
onWebData(java.net.URL url,
java.lang.Object obj,
long fileDate)
This method is invoked when a data record is retrieved from the URL we were invoked on. |
void |
onWebDone()
This method is invoked when the given URL has been fully fetched. |
void |
onWebError(java.lang.String msg)
Handle an error while fetching web data. |
protected void |
process(ContentValues rec)
Optional processing step -- this is called for each record we read. |
void |
setDatabase(SQLiteDatabase db)
Set the database we use for storing our data. |
void |
update(long now)
Check to see whether we need to update our stored data. |
void |
upgradeTable(SQLiteDatabase db,
int oldV,
int newV)
Upgrade or table in the database to a new version. |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WebBasedData(java.lang.String name, java.lang.String base, java.lang.String suff, long interval, boolean ldate, java.lang.String[] fields)
name
- The name of this source, and its database table.base
- The base URL for this source; this is the
whole URL if urlSuff is null.suff
- The URL suffix. If not null, the URL is
urlBase + date + urlSuff, where date is in
the format "20091231".interval
- Interval in ms between records in the source.ldate
- If true, the source uses long-format dates.fields
- Names for the fields in the source.Method Detail |
---|
public void createTable(SQLiteDatabase db)
db
- The database.public void upgradeTable(SQLiteDatabase db, int oldV, int newV)
db
- The database.oldV
- Version we're upgrading from.newV
- Version we're upgrading to.public void setDatabase(SQLiteDatabase db)
db
- The database. Will be null if the database
is being closed.public java.lang.String getName()
public Cursor allRecords()
public Cursor allRecordsSince(long date)
date
- Cut-off date -- only return records newer
than this date (not equal).
public ContentValues lastRecord()
public void update(long now)
now
- The current time in millis.protected void process(ContentValues rec)
rec
- The record to process.public void onWebData(java.net.URL url, java.lang.Object obj, long fileDate)
onWebData
in interface WebFetcher.Listener
url
- The URL of the source being loaded.obj
- The object that was loaded; the type
depends on the fetcher class used.fileDate
- The last modified time of the source file,
as reported by the server, in ms UTC.public void onWebDone()
onWebDone
in interface WebFetcher.Listener
public void onWebError(java.lang.String msg)
onWebError
in interface WebFetcher.Listener
msg
- The error message.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |