public class DownloadFileTask extends PleaseWaitRunnable
Modifier and Type | Class and Description |
---|---|
private static class |
DownloadFileTask.DownloadException |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
address |
private boolean |
canceled |
private HttpClient |
downloadConnection |
private java.io.File |
file |
private boolean |
mkdir |
private boolean |
unpack |
progressMonitor
Constructor and Description |
---|
DownloadFileTask(java.awt.Component parent,
java.lang.String address,
java.io.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(java.io.File file,
java.lang.String dir)
Recursive unzipping function
TODO: May be placed somewhere else - Tools.Utils?
|
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
private final java.lang.String address
private final java.io.File file
private final boolean mkdir
private final boolean unpack
private boolean canceled
private HttpClient downloadConnection
public DownloadFileTask(java.awt.Component parent, java.lang.String address, java.io.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
otherwisejava.lang.IllegalArgumentException
- 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 org.xml.sax.SAXException, java.io.IOException
PleaseWaitRunnable
realRun
in class PleaseWaitRunnable
org.xml.sax.SAXException
- if a SAX error occursjava.io.IOException
- if an I/O error occurspublic boolean isCanceled()
true
if the task was canceled by the user, false
otherwisepublic static void unzipFileRecursively(java.io.File file, java.lang.String dir) throws java.io.IOException
file
- zip filedir
- output directoryjava.io.IOException
- if any I/O error occurs