|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.clients.util.http.Download
Basic HTTP download utility.
Supported API:false
Extendable:false
Nested Class Summary | |
(package private) class |
Download.DownloadThread
Inner class used to avoid declaring Download as Runnable. |
Field Summary | |
private static int |
BUF_SIZ
|
private boolean |
checked
Whether or not a checksum should be calculated. |
private long |
checksum
The checksum of the downloaded file. |
private static Class |
CHECKSUM_CLASS
The class to use to compute checksums. |
private static Class |
DEFAULT_CHECKSUM_CLASS
|
static int |
FAILURE_FILE_NOT_FOUND
Returned by getOperationFailureCode() . |
static int |
FAILURE_HTTP_ERROR
Returned by getOperationFailureCode() . |
static int |
FAILURE_IO_ERROR
Returned by getOperationFailureCode() . |
static int |
FAILURE_NONE
Returned by getOperationFailureCode() . |
private int |
httpResponseCode
The http response code returned from the url connection. |
private String |
httpResponseMessage
The http response message returned from the url connection. |
private Hashtable |
listeners
|
static int |
OPERATION_CANCEL
Returned by getOperationStatus() . |
static int |
OPERATION_CANCEL_REQUEST
Returned by getOperationStatus() . |
static int |
OPERATION_COMPLETE
Returned by getOperationStatus() . |
static int |
OPERATION_FAILURE
Returned by getOperationStatus() . |
static int |
OPERATION_INACTIVE
Returned by getOperationStatus() . |
static int |
OPERATION_START
Returned by getOperationStatus() . |
private Exception |
operationException
Return the operation exception. |
private int |
operationFailureCode
Returned by getOperationFailureCode() . |
private int |
operationStatus
Returned by getOperationStatus() . |
private String |
path
The path of the file to download to. |
private URL |
url
The url to download from. |
private static boolean |
VERBOSE
|
Constructor Summary | |
Download()
Create an unitialized download object. |
|
Download(URL inputURL,
String outputPath)
|
|
Download(URL inputURL,
String outputPath,
boolean a_Checked)
Create a download object which is ready to have the perform operation called. |
Method Summary | |
void |
addDownloadListener(DownloadListener l)
|
void |
cancelOperation()
Cancel the download operation. |
void |
clear()
Clear the download to a state ready for downloading. |
long |
getChecksum()
|
private static Class |
getChecksumClass(String className)
|
int |
getHTTPResponseCode()
Return the HTTP response code when getOperationFailureCode()
returns FAILURE_HTTP_ERROR. |
String |
getHTTPResponseMessage()
Return the HTTP response message when getOperationFailureCode()
returns FAILURE_HTTP_ERROR. |
Exception |
getOperationException()
Return the operation exception. |
int |
getOperationFailureCode()
Return the type of failure encountered. |
int |
getOperationStatus()
Return the status of the download operation (if any). |
String |
getPath()
Return the path for the download. |
URL |
getURL()
Return the URL for the download. |
boolean |
isChecked()
|
private void |
operationProgress(int byteCount)
|
private void |
operationStatusChange(int newStatus)
|
private int |
parseHTTPResponse(URLConnection urlConnection)
Return HTTP reponse code. |
Thread |
performOperation(boolean separateThread)
Perform the download operation. |
void |
removeDownloadListener(DownloadListener l)
|
void |
setChecked(boolean a_Checked)
|
private void |
setHTTPResponseCode(int code)
|
private void |
setHTTPResponseMessage(String message)
|
private void |
setOperationException(Exception e)
|
private void |
setOperationFailureCode(int code)
|
private void |
setOperationStatus(int status)
|
void |
setPath(String path)
Set the path for the download. |
void |
setURL(URL inputURL)
Set the url to be used in the download. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int OPERATION_INACTIVE
getOperationStatus()
. Indicates that no
operation is active.
public static final int OPERATION_START
getOperationStatus()
. Indicates that the
download operation is active.
public static final int OPERATION_CANCEL_REQUEST
getOperationStatus()
. Indicates that the
application has requested that the operation be cancelled.
public static final int OPERATION_CANCEL
getOperationStatus()
. Indicates that the
operation was cancelled at application request.
public static final int OPERATION_COMPLETE
getOperationStatus()
. Indicates that the
operation completed successfully.
public static final int OPERATION_FAILURE
getOperationStatus()
. Indicates that
the operation failed. The operationFailure code indicates the
reason for the failure.
public static final int FAILURE_NONE
getOperationFailureCode()
. Indicates
that no failure has occurred.
public static final int FAILURE_IO_ERROR
getOperationFailureCode()
. Indicates
that some IOException was thrown during the operation.
public static final int FAILURE_HTTP_ERROR
getOperationFailureCode()
. Indicates
that an HTTP error was returned.
public static final int FAILURE_FILE_NOT_FOUND
getOperationFailureCode()
. Indicates
that the file does not exist.
private URL url
private String path
private int httpResponseCode
private String httpResponseMessage
private int operationStatus
getOperationStatus()
. Indicates the status of the
current operation (if any). Values returned are OPERATION_INACTIVE, OPERATION_START,
OPERATION_CANCEL, OPERATION_COMPLETE, OPERATION_FAILURE.
private int operationFailureCode
getOperationFailureCode()
. Indicates the nature of the
operation failure. This value is only valid when getOperationStatus()
returns OPERATION_FAILURE. Values returned are FAILURE_NONE, FAILURE_IO_ERROR,
and FAILURE_FILE_NOT_FOUND.
private Exception operationException
getOperationFailureCode()
is
FAILURE_IO_ERROR or FAILURE_FILE_NOT_FOUND_ERROR.
private long checksum
private static final Class DEFAULT_CHECKSUM_CLASS
private static Class CHECKSUM_CLASS
private static boolean VERBOSE
private static int BUF_SIZ
private boolean checked
private Hashtable listeners
Constructor Detail |
public Download()
setURL()
and
setPath()
must be set before calling operation perform()
.
public Download(URL inputURL, String outputPath)
public Download(URL inputURL, String outputPath, boolean a_Checked)
Method Detail |
public boolean isChecked()
public void setChecked(boolean a_Checked)
public long getChecksum()
public void clear()
public int getOperationStatus()
private void setOperationStatus(int status)
public int getOperationFailureCode()
getOperationStatus()
returns OPERATION_FAILURE. Values returned are
FAILURE_NONE, FAILURE_IO_ERROR, FAILURE_HTTP_ERROR. When FAILURE_HTTP_ERROR
is returned the http response code can be accessed by calling
getHTTPResponseCode()
.
private void setOperationFailureCode(int code)
public Exception getOperationException()
getOperationFailureCode()
is FAILURE_IO_ERROR or FAILURE_FILE_NOT_FOUND error.
private void setOperationException(Exception e)
public URL getURL()
public void setURL(URL inputURL)
public String getPath()
public void setPath(String path)
public int getHTTPResponseCode()
getOperationFailureCode()
returns FAILURE_HTTP_ERROR.
private void setHTTPResponseCode(int code)
public String getHTTPResponseMessage()
getOperationFailureCode()
returns FAILURE_HTTP_ERROR.
private void setHTTPResponseMessage(String message)
public Thread performOperation(boolean separateThread)
getOprerationStatus()
returns OPERATION_COMPLETE, OPERATION_CANCEL, or OPERATION_FAILURE.
separateThread
- when true a separate thread for the download will be created.
public void cancelOperation()
public void addDownloadListener(DownloadListener l)
public void removeDownloadListener(DownloadListener l)
private int parseHTTPResponse(URLConnection urlConnection) throws IOException
IOException
private void operationStatusChange(int newStatus)
private void operationProgress(int byteCount)
private static final Class getChecksumClass(String className)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |