org.hermit.android.net
Class FileFetcher

java.lang.Object
  extended by java.lang.Thread
      extended by org.hermit.android.net.WebFetcher
          extended by org.hermit.android.net.FileFetcher
All Implemented Interfaces:
java.lang.Runnable

public class FileFetcher
extends WebFetcher

Concrete instance of WebFetcher which gets a file and stores it locally. The value passed back to the listener is the local file name as a File.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.hermit.android.net.WebFetcher
WebFetcher.FetchException, WebFetcher.Listener
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class org.hermit.android.net.WebFetcher
dataClient, dataUrls, killed, newerThanDate, timeout
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FileFetcher(Context context, java.net.URL url, java.lang.String name, WebFetcher.Listener client, long timeout)
          Fetch a file from the web.
FileFetcher(Context context, java.net.URL url, java.lang.String name, WebFetcher.Listener client, long timeout, long newer)
          Fetch a file from the web.
 
Method Summary
protected  void handle(java.net.URL url, java.net.URLConnection conn, java.io.InputStream stream)
          Fetch a page of data from the given stream.
 
Methods inherited from class org.hermit.android.net.WebFetcher
fetch, handle, kill, killAll, queue, run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileFetcher

public FileFetcher(Context context,
                   java.net.URL url,
                   java.lang.String name,
                   WebFetcher.Listener client,
                   long timeout)
Fetch a file from the web.

Parameters:
context - Application context.
url - The URL to fetch data from.
name - Local name to save the file as.
client - Client to pass the data to. It will be given the local file name as a File object.
timeout - Maximum time in ms for which the job will be allowed to run.

FileFetcher

public FileFetcher(Context context,
                   java.net.URL url,
                   java.lang.String name,
                   WebFetcher.Listener client,
                   long timeout,
                   long newer)
Fetch a file from the web.

Parameters:
context - Application context.
url - The URL to fetch data from.
name - Local name to save the file as.
client - Client to pass the data to. It will be given the local file name as a File object.
timeout - Maximum time in ms for which the job will be allowed to run.
newer - If-modified-since time in ms UTC. The fetch will only be carried out if the remote resource has been modified since this time. If zero, fetch without this condition.
Method Detail

handle

protected void handle(java.net.URL url,
                      java.net.URLConnection conn,
                      java.io.InputStream stream)
               throws WebFetcher.FetchException,
                      java.io.IOException
Fetch a page of data from the given stream.

Overrides:
handle in class WebFetcher
Parameters:
url - The URL we're reading.
conn - The current connection to the URL.
stream - The InputStream to read from.
Throws:
FetchException - Some problem was detected.
java.io.IOException - An I/O error occurred.
WebFetcher.FetchException