|
||||||||||
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.CachedFile
public class CachedFile
This class manages a set of web-based files and caches them locally. Data about the files is held in a local database.
Nested Class Summary | |
---|---|
static class |
CachedFile.Entry
Class describing an entry in the cache; i.e. |
Constructor Summary | |
---|---|
CachedFile(java.lang.String name,
java.net.URL[] urls)
Create a cache of web-based files. |
Method Summary | |
---|---|
void |
createTable(SQLiteDatabase db)
Create our table in the database. |
CachedFile.Entry |
getFile(java.net.URL url)
Query for a given file in the cache. |
void |
invalidate(java.net.URL url)
Invalidate the given file in the cache (perhaps it was corrupted). |
void |
onWebData(java.net.URL url,
java.lang.Object obj,
long date)
This method is invoked when a data item 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. |
void |
setDatabase(SQLiteDatabase db)
Set the database we use for storing our data. |
void |
update(Context context,
long now)
Check to see whether we need to update our cached copies of the files. |
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 CachedFile(java.lang.String name, java.net.URL[] urls)
name
- The name of this source, and its database table.urls
- The list of URLs to cache.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 CachedFile.Entry getFile(java.net.URL url)
url
- The URL of the file we want.
public void invalidate(java.net.URL url)
url
- The URL of the file to invalidate.public void update(Context context, long now)
context
- The application context. Used for
determining where the local files are kept.now
- The current time in millis.public void onWebData(java.net.URL url, java.lang.Object obj, long date)
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.date
- 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 |