Interface TimeoutConstrainedURLHandler
- All Superinterfaces:
URLHandler
- All Known Implementing Classes:
BasicURLHandler, HttpClientHandler, URLHandlerDispatcher
A enhanced version of
URLHandler which respects TimeoutConstraints on
the operations dealing with download, upload, reachability checks etc...-
Nested Class Summary
Nested classes/interfaces inherited from interface URLHandler
URLHandler.URLInfo -
Field Summary
Fields inherited from interface URLHandler
REQUEST_METHOD_GET, REQUEST_METHOD_HEAD, UNAVAILABLE -
Method Summary
Modifier and TypeMethodDescriptionvoiddownload(URL src, File dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) Downloads the resource available atsrcto the targetdestlonggetContentLength(URL url, TimeoutConstraint timeoutConstraint) Returns the number of bytes of data that's available for the resource at the passedurl.longgetLastModified(URL url, TimeoutConstraint timeoutConstraint) Returns the last modified timestamp of the resource accessible at the passedurl.getURLInfo(URL url, TimeoutConstraint timeoutConstraint) Returns theURLHandler.URLInfoextracted from the given url, orURLHandler.UNAVAILABLEwhen the url is not reachable.booleanisReachable(URL url, TimeoutConstraint timeoutConstraint) Returns true if the passedURLis reachable.openStream(URL url, TimeoutConstraint timeoutConstraint) Opens and returns anInputStreamto the passedurl.voidupload(File src, URL dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) Methods inherited from interface URLHandler
download, getContentLength, getContentLength, getLastModified, getLastModified, getURLInfo, getURLInfo, isReachable, isReachable, openStream, setRequestMethod, upload
-
Method Details
-
isReachable
Returns true if the passedURLis reachable. Else returns false. Uses the passedtimeoutConstraintfor determining the connectivity to the URL.Please use
getURLInfo(URL, TimeoutConstraint)if more one information about theurlis needed- Parameters:
url- The URL to accesstimeoutConstraint- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- boolean
- Since:
- 2.5
-
getContentLength
Returns the number of bytes of data that's available for the resource at the passedurl. Returns 0 if the passedurlisn't reachable- Parameters:
url- The URL to accesstimeoutConstraint- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- long
- Since:
- 2.5
-
getLastModified
Returns the last modified timestamp of the resource accessible at the passedurl.Please use
getURLInfo(URL, TimeoutConstraint)if more one information about theurlis needed- Parameters:
url- The URL to accesstimeoutConstraint- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- long
- Since:
- 2.5
-
getURLInfo
Returns theURLHandler.URLInfoextracted from the given url, orURLHandler.UNAVAILABLEwhen the url is not reachable. Never returns null.- Parameters:
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 specific- Returns:
- URLInfo
- Since:
- 2.5
-
openStream
Opens and returns anInputStreamto the passedurl.- Parameters:
url- The URL to which anInputStreamhas to be openedtimeoutConstraint- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- InputStream
- Throws:
IOException- if something goes wrong- Since:
- 2.5
-
download
void download(URL src, File dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) throws IOException Downloads the resource available atsrcto the targetdest- Parameters:
src- The source URL to download the resource fromdest- The destinationFileto 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 specific- Throws:
IOException- if something goes wrong- Since:
- 2.5
-
upload
void upload(File src, URL dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) throws IOException - Parameters:
src- The sourceFileto uploaddest- The target URL where theFilehas 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 specific- Throws:
IOException- if something goes wrong- Since:
- 2.5
-