public class DownloadFileTask extends PleaseWaitRunnable
Modifier and Type | Class and Description |
---|---|
private static class |
DownloadFileTask.DownloadException |
Modifier and Type | Field and Description |
---|---|
private String |
address |
private boolean |
canceled |
private HttpClient |
downloadConnection |
private File |
file |
private boolean |
mkdir |
private boolean |
unpack |
progressMonitor
Constructor and Description |
---|
DownloadFileTask(Component parent,
String address,
File file,
boolean mkdir,
boolean unpack)
Creates the download task
|
Modifier and Type | Method and Description |
---|---|
protected void |
cancel()
User pressed cancel button.
|
private void |
closeConnectionIfNeeded() |
void |
download()
Performs download.
|
protected void |
finish()
Finish up the data work.
|
boolean |
isCanceled()
Replies true if the task was canceled by the user
|
protected void |
realRun()
Called in the worker thread to do the actual work.
|
static void |
unzipFileRecursively(File file,
String dir)
Recursive unzipping function
TODO: May be placed somewhere else - Tools.Utils?
|
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
private final boolean mkdir
private final boolean unpack
private boolean canceled
private HttpClient downloadConnection
public DownloadFileTask(Component parent, String address, File file, boolean mkdir, boolean unpack)
parent
- the parent component relative to which the PleaseWaitDialog
is displayedaddress
- the URL to downloadfile
- The destination filemkdir
- true
if the destination directory must be created, false
otherwiseunpack
- true
if zip archives must be unpacked recursively, false
otherwiseIllegalArgumentException
- if parent
is nullprivate void closeConnectionIfNeeded()
protected void cancel()
PleaseWaitRunnable
cancel
in class PleaseWaitRunnable
protected void finish()
PleaseWaitRunnable
finish
in class PleaseWaitRunnable
public void download() throws DownloadFileTask.DownloadException
DownloadFileTask.DownloadException
- if the URL is invalid or if any I/O error occurs.protected void realRun() throws SAXException, IOException
PleaseWaitRunnable
realRun
in class PleaseWaitRunnable
SAXException
- if a SAX error occursIOException
- if an I/O error occurspublic boolean isCanceled()
true
if the task was canceled by the user, false
otherwisepublic static void unzipFileRecursively(File file, String dir) throws IOException
file
- zip filedir
- output directoryIOException
- if any I/O error occurs