|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread com.isti.util.IstiThread com.isti.util.IstiNotifyThread com.isti.util.FileDownloader
public class FileDownloader
Class FileDownloader downloads a file with optional dialogs.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class com.isti.util.IstiThread |
---|
DEFAULT_TERMINATE_WAIT_TIME, terminateFlag |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
FileDownloader(java.lang.String fileNameStr,
java.io.File outputDir,
CallBackStringParam callBackObj,
IstiDialogInterface dialogObj,
ProgressIndicatorInterface progressBarObj)
Creates a file download thread. |
|
FileDownloader(java.lang.String fileNameStr,
java.io.File outputDir,
CallBackStringParam callBackObj,
IstiDialogInterface dialogObj,
ProgressIndicatorInterface progressBarObj,
boolean unzipDownloadedFileFlag)
Creates a file download thread. |
Method Summary | |
---|---|
protected void |
backupOutputFile()
Backup the output file. |
protected java.lang.String |
checkConnection(java.net.URLConnection urlCon)
Checks the connection. |
protected java.lang.String |
checkHttpURLConnection(java.net.HttpURLConnection htpUrlCon)
Checks the HTTP connection. |
protected boolean |
checkLastModified()
Checks the last modified time. |
protected boolean |
checkLastModified(long inputLastModified,
long outputLastModified)
Checks the last modified time. |
protected void |
closeStreams()
Closes the streams. |
protected void |
doThreadFinished(java.lang.String errMsgStr)
Performs thread-finished operations. |
protected java.io.File |
getBackupFile(java.io.File outputFile)
Gets the backup file for the specified output file. |
java.io.File |
getOutputFileObj()
Returns the file object for the last file downloaded (or attempted). |
protected void |
initProgressBar()
Initialize the progress bar. |
boolean |
isCloseWhenDone()
Determines if dialog is closed when the download is done. |
boolean |
isDownloadDone()
Returns the completion status of the download attempt. |
void |
requestDialogFocus()
Perfoms a 'requestFocus()' on the currently-displayed dialog (if any). |
void |
run()
Runs the thread. |
void |
setBackupFile(boolean b)
Determines if the output file should be backed up if it already exists. |
void |
setCallBackObj(CallBackStringParam callBackObj)
Sets the call-back object to use used. |
void |
setCheckConnection(boolean b)
Determines if the connection should be checked. |
void |
setCheckLastModified(boolean b)
Determines if the last modified time should be checked. |
void |
setCloseWhenDone(boolean b)
Sets if the dialog is closed when the download is done. |
void |
setDeleteFileAfterUnzip(boolean b)
Determines if the file should be deleted after unzip. |
protected void |
setDownloadDone(java.lang.String errMsgStr)
Sets the download done. |
void |
terminate()
Deprecated. Should use the terminateThread method instead. |
void |
terminateThread(java.lang.String msgStr)
Terminates this download thread. |
protected void |
threadFinished(java.lang.String errMsgStr)
Performs thread-finished operations (if terminate flag not set). |
protected void |
transferStream(java.io.InputStream inputStream,
java.io.OutputStream outputStream)
Transfers data from the input stream to the output stream. |
protected void |
unzipZipFile()
Unzip the file. |
Methods inherited from class com.isti.util.IstiNotifyThread |
---|
sleep |
Methods inherited from class com.isti.util.IstiThread |
---|
clearThreadWaitNotifyFlag, isTerminated, nextThreadNum, notifyThread, start, terminate, waitForNotify, waitForNotify, waitForTerminate, waitForTerminate, wasStarted |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, 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, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FileDownloader(java.lang.String fileNameStr, java.io.File outputDir, CallBackStringParam callBackObj, IstiDialogInterface dialogObj, ProgressIndicatorInterface progressBarObj, boolean unzipDownloadedFileFlag)
fileNameStr
- the installer file name string.outputDir
- the output directory.callBackObj
- if not null then a call-back object whose method
is called (after the download is complete) with a string parameter
containing null if successful or an error message if an error occurred.dialogObj
- the dialog object or null for none.progressBarObj
- the progress bar object or null for none.unzipDownloadedFileFlag
- true to unzip file after download (if
it is a ZIP file); false to not unzip file.public FileDownloader(java.lang.String fileNameStr, java.io.File outputDir, CallBackStringParam callBackObj, IstiDialogInterface dialogObj, ProgressIndicatorInterface progressBarObj)
fileNameStr
- the installer file name string.outputDir
- the output directory.callBackObj
- if not null then a call-back object whose method
is called (after the download is complete) with a string parameter
containing null if successful or an error message if an error occurred.dialogObj
- the dialog object or null for none.progressBarObj
- the progress bar object or null for none.Method Detail |
---|
public void setBackupFile(boolean b)
b
- true if the output file should be backed up if it already exists.public void setCallBackObj(CallBackStringParam callBackObj)
callBackObj
- if not null then a call-back object whose method
is called (after the download is complete) with a string parameter
containing null if successful or an error message if an error occurred.public void setCheckConnection(boolean b)
b
- true if the connection should be checked.public void setCheckLastModified(boolean b)
b
- true if the last modified time should be checked.public void setCloseWhenDone(boolean b)
b
- true if dialog is closed when the download is done, false
otherwise.public void setDeleteFileAfterUnzip(boolean b)
b
- true if the file should be deleted after unzip.protected void backupOutputFile()
protected java.lang.String checkConnection(java.net.URLConnection urlCon) throws java.io.IOException
urlCon
- the URL connection.
java.io.IOException
- if an I/O error has occurred.protected java.lang.String checkHttpURLConnection(java.net.HttpURLConnection htpUrlCon) throws java.io.IOException
htpUrlCon
- the HTTP URL connection.
java.io.IOException
- if an I/O error has occurred.protected boolean checkLastModified()
protected boolean checkLastModified(long inputLastModified, long outputLastModified)
inputLastModified
- the input last modified time.outputLastModified
- the output last modified time.
protected java.io.File getBackupFile(java.io.File outputFile)
outputFile
- the output file.
protected void initProgressBar()
protected void unzipZipFile() throws java.io.IOException, java.util.zip.ZipException
java.util.zip.ZipException
- if a ZIP error has occurred.
java.io.IOException
- if an I/O error has occurred.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
protected void setDownloadDone(java.lang.String errMsgStr)
errMsgStr
- error message to be entered into the call-back
object, or null for none.protected void closeStreams()
protected void transferStream(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException
inputStream
- the input stream.outputStream
- the output stream.
java.io.IOException
- if an I/O error occurs.protected void threadFinished(java.lang.String errMsgStr)
errMsgStr
- error message to be entered into the call-back
object, or null for none.protected void doThreadFinished(java.lang.String errMsgStr)
errMsgStr
- error message to be entered into the call-back
object, or null for none.public void terminate()
terminateThread
method instead.
terminate
in class IstiNotifyThread
terminateThread
public void terminateThread(java.lang.String msgStr)
msgStr
- message string given to call-back object.public void requestDialogFocus()
public boolean isCloseWhenDone()
public boolean isDownloadDone()
public java.io.File getOutputFileObj()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |