public abstract class FileAsyncHttpResponseHandler extends AsyncHttpResponseHandler
Modifier and Type | Field and Description |
---|---|
protected boolean |
append |
protected java.io.File |
file |
protected java.io.File |
frontendFile |
protected boolean |
renameIfExists |
BUFFER_SIZE, CANCEL_MESSAGE, DEFAULT_CHARSET, FAILURE_MESSAGE, FINISH_MESSAGE, PROGRESS_MESSAGE, RETRY_MESSAGE, START_MESSAGE, SUCCESS_MESSAGE, UTF8_BOM
Constructor and Description |
---|
FileAsyncHttpResponseHandler(android.content.Context context)
Obtains new FileAsyncHttpResponseHandler against context with target being temporary file
|
FileAsyncHttpResponseHandler(java.io.File file)
Obtains new FileAsyncHttpResponseHandler and stores response in passed file
|
FileAsyncHttpResponseHandler(java.io.File file,
boolean append)
Obtains new FileAsyncHttpResponseHandler and stores response in passed file
|
FileAsyncHttpResponseHandler(java.io.File file,
boolean append,
boolean renameTargetFileIfExists)
Obtains new FileAsyncHttpResponseHandler and stores response in passed file
|
FileAsyncHttpResponseHandler(java.io.File file,
boolean append,
boolean renameTargetFileIfExists,
boolean usePoolThread)
Obtains new FileAsyncHttpResponseHandler and stores response in passed file
|
Modifier and Type | Method and Description |
---|---|
boolean |
deleteTargetFile()
Attempts to delete file with stored response
|
protected java.io.File |
getOriginalFile()
Retrieves File object in which the response is stored
|
protected byte[] |
getResponseData(cz.msebera.android.httpclient.HttpEntity entity)
Returns byte array of response HttpEntity contents
|
java.io.File |
getTargetFile()
Retrieves File which represents response final location after possible renaming
|
protected java.io.File |
getTargetFileByParsingURL()
Will return File instance for file representing last URL segment in given folder.
|
protected java.io.File |
getTemporaryFile(android.content.Context context)
Used when there is no file to be used when calling constructor
|
void |
onFailure(int statusCode,
cz.msebera.android.httpclient.Header[] headers,
byte[] responseBytes,
java.lang.Throwable throwable)
Fired when a request fails to complete, override to handle in your own code
|
abstract void |
onFailure(int statusCode,
cz.msebera.android.httpclient.Header[] headers,
java.lang.Throwable throwable,
java.io.File file)
Method to be overriden, receives as much of file as possible Called when the file is
considered failure or if there is error when retrieving file
|
void |
onSuccess(int statusCode,
cz.msebera.android.httpclient.Header[] headers,
byte[] responseBytes)
Fired when a request returns successfully, override to handle in your own code
|
abstract void |
onSuccess(int statusCode,
cz.msebera.android.httpclient.Header[] headers,
java.io.File file)
Method to be overriden, receives as much of response as possible
|
getCharset, getRequestHeaders, getRequestURI, getTag, getUsePoolThread, getUseSynchronousMode, handleMessage, obtainMessage, onCancel, onFinish, onPostProcessResponse, onPreProcessResponse, onProgress, onRetry, onStart, onUserException, postRunnable, sendCancelMessage, sendFailureMessage, sendFinishMessage, sendMessage, sendProgressMessage, sendResponseMessage, sendRetryMessage, sendStartMessage, sendSuccessMessage, setCharset, setRequestHeaders, setRequestURI, setTag, setUsePoolThread, setUseSynchronousMode
protected final java.io.File file
protected final boolean append
protected final boolean renameIfExists
protected java.io.File frontendFile
public FileAsyncHttpResponseHandler(java.io.File file)
file
- File to store response within, must not be nullpublic FileAsyncHttpResponseHandler(java.io.File file, boolean append)
file
- File to store response within, must not be nullappend
- whether data should be appended to existing filepublic FileAsyncHttpResponseHandler(java.io.File file, boolean append, boolean renameTargetFileIfExists)
file
- File to store response within, must not be nullappend
- whether data should be appended to existing filerenameTargetFileIfExists
- whether target file should be renamed if it already existspublic FileAsyncHttpResponseHandler(java.io.File file, boolean append, boolean renameTargetFileIfExists, boolean usePoolThread)
file
- File to store response within, must not be nullappend
- whether data should be appended to existing filerenameTargetFileIfExists
- whether target file should be renamed if it already existsusePoolThread
- Whether to use the pool's thread to fire callbackspublic FileAsyncHttpResponseHandler(android.content.Context context)
context
- Context, must not be nullpublic boolean deleteTargetFile()
protected java.io.File getTemporaryFile(android.content.Context context)
context
- Context, must not be nullprotected java.io.File getOriginalFile()
public java.io.File getTargetFile()
protected java.io.File getTargetFileByParsingURL()
public final void onFailure(int statusCode, cz.msebera.android.httpclient.Header[] headers, byte[] responseBytes, java.lang.Throwable throwable)
AsyncHttpResponseHandler
onFailure
in class AsyncHttpResponseHandler
statusCode
- return HTTP status codeheaders
- return headers, if anyresponseBytes
- the response body, if anythrowable
- the underlying cause of the failurepublic abstract void onFailure(int statusCode, cz.msebera.android.httpclient.Header[] headers, java.lang.Throwable throwable, java.io.File file)
statusCode
- http file status lineheaders
- file http headers if anythrowable
- returned throwablefile
- file in which the file is storedpublic final void onSuccess(int statusCode, cz.msebera.android.httpclient.Header[] headers, byte[] responseBytes)
AsyncHttpResponseHandler
onSuccess
in class AsyncHttpResponseHandler
statusCode
- the status code of the responseheaders
- return headers, if anyresponseBytes
- the body of the HTTP response from the serverpublic abstract void onSuccess(int statusCode, cz.msebera.android.httpclient.Header[] headers, java.io.File file)
statusCode
- http response status lineheaders
- response http headers if anyfile
- file in which the response is storedprotected byte[] getResponseData(cz.msebera.android.httpclient.HttpEntity entity) throws java.io.IOException
AsyncHttpResponseHandler
entity
- can be nulljava.io.IOException
- if reading entity or creating byte array failed