public class OkHttpDownloadAction extends java.lang.Object implements DownloadAction
DownloadAction.
Created by covers1624 on 20/11/21.
DownloadAction.Dest| Constructor and Description |
|---|
OkHttpDownloadAction() |
| Modifier and Type | Method and Description |
|---|---|
OkHttpDownloadAction |
addTag(java.lang.Class<?> clazz,
java.lang.Object tag)
Add a Tag to the OkHttp
Request. |
void |
execute()
Execute the download action.
|
OkHttpClient |
getClient() |
DownloadAction.Dest |
getDest() |
DownloadListener |
getDownloadListener() |
boolean |
getOnlyIfModified() |
boolean |
getQuiet() |
java.util.Map<java.lang.Class<?>,java.lang.Object> |
getTags() |
java.lang.String |
getUrl() |
boolean |
getUseETag() |
java.lang.String |
getUserAgent() |
boolean |
isUpToDate() |
OkHttpDownloadAction |
setClient(OkHttpClient client)
Set the
OkHttpClient client to use. |
OkHttpDownloadAction |
setDest(DownloadAction.Dest dest)
Set the Destination to download content to.
|
OkHttpDownloadAction |
setDest(java.io.File file)
Set the
File to download content to. |
DownloadAction |
setDest(java.io.OutputStream os)
Set the
OutputStream to download content to. |
OkHttpDownloadAction |
setDest(java.nio.file.Path path)
Set the
Path to download content to. |
OkHttpDownloadAction |
setDest(java.io.StringWriter sw)
Set the
StringWriter to download content to. |
OkHttpDownloadAction |
setDownloadListener(DownloadListener downloadListener)
Set the
DownloadListener to use. |
OkHttpDownloadAction |
setOnlyIfModified(boolean onlyIfModified)
If this Download action should use
If-Modified-Since
HTTP request header. |
OkHttpDownloadAction |
setQuiet(boolean quiet)
If this download action should not log things.
|
OkHttpDownloadAction |
setUrl(java.lang.String url)
Set the URL to download from.
|
OkHttpDownloadAction |
setUseETag(boolean useETag)
If this download action should use
If-None-Match
HTTP request header. |
OkHttpDownloadAction |
setUserAgent(java.lang.String userAgent)
Sets the
User-Agent HTTP request header. |
public void execute()
throws java.io.IOException
execute in interface DownloadActionjava.io.IOException - If an IO error occurs whilst downloading.HttpResponseException - If the response code was not expected.public OkHttpDownloadAction setClient(OkHttpClient client)
OkHttpClient client to use.client - The OkHttpClient.public OkHttpDownloadAction setUrl(java.lang.String url)
DownloadActionsetUrl in interface DownloadActionurl - The URL.public OkHttpDownloadAction setDest(DownloadAction.Dest dest)
DownloadActionsetDest in interface DownloadActiondest - The Destination.public OkHttpDownloadAction setDest(java.io.StringWriter sw)
DownloadActionStringWriter to download content to.setDest in interface DownloadActionsw - The StringWriter.public DownloadAction setDest(java.io.OutputStream os)
DownloadActionOutputStream to download content to.setDest in interface DownloadActionos - The OutputStream.public OkHttpDownloadAction setDest(java.io.File file)
DownloadActionFile to download content to.setDest in interface DownloadActionfile - The file.public OkHttpDownloadAction setDest(java.nio.file.Path path)
DownloadActionPath to download content to.setDest in interface DownloadActionpath - The path.public OkHttpDownloadAction setOnlyIfModified(boolean onlyIfModified)
DownloadActionIf-Modified-Since
HTTP request header.setOnlyIfModified in interface DownloadActiononlyIfModified - If If-Modified-Since should be used.public OkHttpDownloadAction setUseETag(boolean useETag)
DownloadActionIf-None-Match
HTTP request header.setUseETag in interface DownloadActionuseETag - If If-None-Match should be used.public OkHttpDownloadAction setQuiet(boolean quiet)
DownloadActionsetQuiet in interface DownloadActionquiet - If the download action should be quiet.public OkHttpDownloadAction setUserAgent(java.lang.String userAgent)
DownloadActionUser-Agent HTTP request header.setUserAgent in interface DownloadActionuserAgent - The User-Agent request header.public OkHttpDownloadAction setDownloadListener(DownloadListener downloadListener)
DownloadActionDownloadListener to use.setDownloadListener in interface DownloadActiondownloadListener - The DownloadListener.public OkHttpDownloadAction addTag(java.lang.Class<?> clazz, java.lang.Object tag)
Request.clazz - The Tag type.tag - The tag.public boolean isUpToDate()
isUpToDate in interface DownloadActionpublic OkHttpClient getClient()
public java.lang.String getUrl()
getUrl in interface DownloadActionpublic DownloadAction.Dest getDest()
getDest in interface DownloadActionpublic boolean getOnlyIfModified()
getOnlyIfModified in interface DownloadActionpublic boolean getUseETag()
getUseETag in interface DownloadActionpublic boolean getQuiet()
getQuiet in interface DownloadActionpublic java.lang.String getUserAgent()
getUserAgent in interface DownloadActionpublic DownloadListener getDownloadListener()
getDownloadListener in interface DownloadActionpublic java.util.Map<java.lang.Class<?>,java.lang.Object> getTags()