public class BasicURLHandler extends AbstractURLHandler implements TimeoutConstrainedURLHandler
URLHandler.URLInfoREQUEST_METHOD_GET, REQUEST_METHOD_HEAD, UNAVAILABLE| Constructor and Description |
|---|
BasicURLHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
download(java.net.URL src,
java.io.File dest,
CopyProgressListener l) |
void |
download(java.net.URL src,
java.io.File dest,
CopyProgressListener listener,
TimeoutConstraint timeoutConstraint)
Downloads the resource available at
src to the target dest |
static java.lang.String |
getCharSetFromContentType(java.lang.String contentType)
Extract the charset from the Content-Type header string, or default to ISO-8859-1 as per
rfc2616-sec3.html#sec3.7.1 .
|
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) |
URLHandler.URLInfo |
getURLInfo(java.net.URL url,
int timeout) |
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) |
java.io.InputStream |
openStream(java.net.URL url,
TimeoutConstraint timeoutConstraint)
Opens and returns an
InputStream to the passed url. |
void |
upload(java.io.File source,
java.net.URL dest,
CopyProgressListener l) |
void |
upload(java.io.File src,
java.net.URL dest,
CopyProgressListener listener,
TimeoutConstraint timeoutConstraint)
Uploads the
src File to the target dest URL |
createTimeoutConstraints, getContentLength, getContentLength, getDecodingInputStream, getLastModified, getLastModified, getRequestMethod, getUserAgent, isReachable, isReachable, normalizeToString, normalizeToURL, setRequestMethod, validatePutStatusCodeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetContentLength, getContentLength, getLastModified, getLastModified, isReachable, isReachable, setRequestMethodpublic URLHandler.URLInfo getURLInfo(java.net.URL url)
getURLInfo in interface URLHandlerurl - The url from which information is retrieved.URLHandler.UNAVAILABLE instance when the
url is not reachable.public URLHandler.URLInfo getURLInfo(java.net.URL url, int timeout)
getURLInfo in interface URLHandlerurl - The url from which information is retrieved.timeout - The timeout in milliseconds.URLHandler.UNAVAILABLE when the url is
not reachable, never null.public boolean isReachable(java.net.URL url,
TimeoutConstraint timeoutConstraint)
TimeoutConstrainedURLHandlerURL is reachable. Else returns false. Uses the
passed timeoutConstraint for determining the connectivity to the URL.
Please use TimeoutConstrainedURLHandler.getURLInfo(URL, TimeoutConstraint) if more one information about the
url is needed
isReachable in interface TimeoutConstrainedURLHandlerurl - The URL to accesstimeoutConstraint - The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificpublic long getContentLength(java.net.URL url,
TimeoutConstraint timeoutConstraint)
TimeoutConstrainedURLHandlerurl. Returns 0 if the passed url isn't reachablegetContentLength in interface TimeoutConstrainedURLHandlerurl - The URL to accesstimeoutConstraint - The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificpublic long getLastModified(java.net.URL url,
TimeoutConstraint timeoutConstraint)
TimeoutConstrainedURLHandlerurl.
Please use TimeoutConstrainedURLHandler.getURLInfo(URL, TimeoutConstraint) if more one information about the
url is needed
getLastModified in interface TimeoutConstrainedURLHandlerurl - The URL to accesstimeoutConstraint - The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificpublic URLHandler.URLInfo getURLInfo(java.net.URL url, TimeoutConstraint timeoutConstraint)
TimeoutConstrainedURLHandlerURLInfo extracted from the given url, or URLHandler.UNAVAILABLE when the
url is not reachable. Never returns null.getURLInfo in interface TimeoutConstrainedURLHandlerurl - The URL for which the information is to be retrievedtimeoutConstraint - The connectivity timeout constraints. Can be null, in which case
the timeouts are implementation specificpublic static java.lang.String getCharSetFromContentType(java.lang.String contentType)
contentType - the Content-Type header stringpublic java.io.InputStream openStream(java.net.URL url)
throws java.io.IOException
openStream in interface URLHandlerurl - dittojava.io.IOException - if something goes wrongpublic java.io.InputStream openStream(java.net.URL url,
TimeoutConstraint timeoutConstraint)
throws java.io.IOException
TimeoutConstrainedURLHandlerInputStream to the passed url.openStream in interface TimeoutConstrainedURLHandlerurl - 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 wrongpublic void download(java.net.URL src,
java.io.File dest,
CopyProgressListener l)
throws java.io.IOException
download in interface URLHandlersrc - URLdest - Filel - CopyProgressListenerjava.io.IOException - if something goes wrongpublic void download(java.net.URL src,
java.io.File dest,
CopyProgressListener listener,
TimeoutConstraint timeoutConstraint)
throws java.io.IOException
TimeoutConstrainedURLHandlersrc to the target destdownload in interface TimeoutConstrainedURLHandlersrc - 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 wrongpublic void upload(java.io.File source,
java.net.URL dest,
CopyProgressListener l)
throws java.io.IOException
upload in interface URLHandlersource - Filedest - URLl - CopyProgressListenerjava.io.IOException - if something goes wrongpublic void upload(java.io.File src,
java.net.URL dest,
CopyProgressListener listener,
TimeoutConstraint timeoutConstraint)
throws java.io.IOException
TimeoutConstrainedURLHandlersrc File to the target dest URLupload in interface TimeoutConstrainedURLHandlersrc - 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-2024 The Apache Software Foundation, Licensed under Apache License, Version 2.0.