com.threerings.getdown.net
Class Downloader

java.lang.Object
  extended by java.lang.Thread
      extended by com.threerings.getdown.net.Downloader
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
HTTPDownloader

public abstract class Downloader
extends Thread

Handles the download of a collection of files, first issuing HTTP head requests to obtain size information and then downloading the files individually, reporting progress back via a callback interface.


Nested Class Summary
static interface Downloader.Observer
          An interface used to communicate status back to an external entity.
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Downloader(List<Resource> resources, Downloader.Observer obs)
          Creates a downloader that will download the supplied list of resources and communicate with the specified observer.
 
Method Summary
 boolean download()
          Start downloading the resources in this downloader.
 void run()
          This method is invoked as the downloader thread and performs the actual downloading.
 
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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Downloader

public Downloader(List<Resource> resources,
                  Downloader.Observer obs)
Creates a downloader that will download the supplied list of resources and communicate with the specified observer. The download() method must be called on the downloader to initiate the download process.

Method Detail

run

public void run()
This method is invoked as the downloader thread and performs the actual downloading.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

download

public boolean download()
Start downloading the resources in this downloader.

Returns:
true if the download completed or failed for unexpected reasons (in which case the observer will have been notified), false if it was aborted by the observer.


Copyright © 2013. All Rights Reserved.