public interface TimeoutConstrainedURLHandler extends URLHandler
URLHandler
which respects TimeoutConstraint
s on
the operations dealing with download, upload, reachability checks etc...URLHandler.URLInfo
REQUEST_METHOD_GET, REQUEST_METHOD_HEAD, UNAVAILABLE
Modifier and Type | Method and Description |
---|---|
void |
download(java.net.URL src,
java.io.File dest,
CopyProgressListener listener,
TimeoutConstraint timeoutConstraint)
Downloads the resource available at
src to the target dest |
long |
getContentLength(java.net.URL url,
TimeoutConstraint timeoutConstraint)
Returns the number of bytes of data that's available for the resource at the passed
url . |
long |
getLastModified(java.net.URL url,
TimeoutConstraint timeoutConstraint)
Returns the last modified timestamp of the resource accessible at the passed
url . |
URLHandler.URLInfo |
getURLInfo(java.net.URL url,
TimeoutConstraint timeoutConstraint)
Returns the
URLInfo extracted from the given url, or URLHandler.UNAVAILABLE when the
url is not reachable. |
boolean |
isReachable(java.net.URL url,
TimeoutConstraint timeoutConstraint)
Returns true if the passed
URL is reachable. |
java.io.InputStream |
openStream(java.net.URL url,
TimeoutConstraint timeoutConstraint)
Opens and returns an
InputStream to the passed url . |
void |
upload(java.io.File src,
java.net.URL dest,
CopyProgressListener listener,
TimeoutConstraint timeoutConstraint)
Uploads the
src File to the target dest URL |
download, getContentLength, getContentLength, getLastModified, getLastModified, getURLInfo, getURLInfo, isReachable, isReachable, openStream, setRequestMethod, upload
boolean isReachable(java.net.URL url, TimeoutConstraint timeoutConstraint)
URL
is reachable. Else returns false. Uses the
passed timeoutConstraint
for determining the connectivity to the URL.
Please use getURLInfo(URL, TimeoutConstraint)
if more one information about the
url
is needed
url
- The URL to accesstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificlong getContentLength(java.net.URL url, TimeoutConstraint timeoutConstraint)
url
. Returns 0 if the passed url
isn't reachableurl
- The URL to accesstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificlong getLastModified(java.net.URL url, TimeoutConstraint timeoutConstraint)
url
.
Please use getURLInfo(URL, TimeoutConstraint)
if more one information about the
url
is needed
url
- The URL to accesstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificURLHandler.URLInfo getURLInfo(java.net.URL url, TimeoutConstraint timeoutConstraint)
URLInfo
extracted from the given url, or URLHandler.UNAVAILABLE
when the
url is not reachable. Never returns null.url
- The URL for which the information is to be retrievedtimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificjava.io.InputStream openStream(java.net.URL url, TimeoutConstraint timeoutConstraint) throws java.io.IOException
InputStream
to the passed url
.url
- The URL to which an InputStream
has to be openedtimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificjava.io.IOException
- if something goes wrongvoid download(java.net.URL src, java.io.File dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) throws java.io.IOException
src
to the target dest
src
- The source URL to download the resource fromdest
- The destination File
to download the resource tolistener
- The listener that will be notified of the download progresstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificjava.io.IOException
- if something goes wrongvoid upload(java.io.File src, java.net.URL dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) throws java.io.IOException
src
File
to the target dest
URL
src
- The source File
to uploaddest
- The target URL where the File
has to be uploadedlistener
- The listener that will be notified of the upload progresstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificjava.io.IOException
- if something goes wrongCopyright ©2007-2022 The Apache Software Foundation, Licensed under Apache License, Version 2.0.