Class BasicURLHandler
java.lang.Object
org.apache.ivy.util.url.AbstractURLHandler
org.apache.ivy.util.url.BasicURLHandler
- All Implemented Interfaces:
TimeoutConstrainedURLHandler, URLHandler
-
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddownload(URL src, File dest, CopyProgressListener l) voiddownload(URL src, File dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) Downloads the resource available atsrcto the targetdeststatic StringgetCharSetFromContentType(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 .longgetContentLength(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) getURLInfo(URL url, int timeout) 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) openStream(URL url, TimeoutConstraint timeoutConstraint) Opens and returns anInputStreamto the passedurl.voidupload(File source, URL dest, CopyProgressListener l) voidupload(File src, URL dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) Methods inherited from class AbstractURLHandler
createTimeoutConstraints, getContentLength, getContentLength, getDecodingInputStream, getLastModified, getLastModified, getRequestMethod, getUserAgent, isReachable, isReachable, normalizeToString, normalizeToURL, setRequestMethod, validatePutStatusCodeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface URLHandler
getContentLength, getContentLength, getLastModified, getLastModified, isReachable, isReachable, setRequestMethod
-
Constructor Details
-
BasicURLHandler
public BasicURLHandler()
-
-
Method Details
-
getURLInfo
- Specified by:
getURLInfoin interfaceURLHandler- Parameters:
url- The url from which information is retrieved.- Returns:
- The URLInfo extracted from the given url, or
URLHandler.UNAVAILABLEinstance when the url is not reachable.
-
getURLInfo
- Specified by:
getURLInfoin interfaceURLHandler- Parameters:
url- The url from which information is retrieved.timeout- The timeout in milliseconds.- Returns:
- The URLInfo extracted from the given url, or
URLHandler.UNAVAILABLEwhen the url is not reachable, never null.
-
isReachable
Description copied from interface:TimeoutConstrainedURLHandlerReturns true if the passedURLis reachable. Else returns false. Uses the passedtimeoutConstraintfor determining the connectivity to the URL.Please use
TimeoutConstrainedURLHandler.getURLInfo(URL, TimeoutConstraint)if more one information about theurlis needed- Specified by:
isReachablein interfaceTimeoutConstrainedURLHandler- Parameters:
url- The URL to accesstimeoutConstraint- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- boolean
-
getContentLength
Description copied from interface:TimeoutConstrainedURLHandlerReturns the number of bytes of data that's available for the resource at the passedurl. Returns 0 if the passedurlisn't reachable- Specified by:
getContentLengthin interfaceTimeoutConstrainedURLHandler- Parameters:
url- The URL to accesstimeoutConstraint- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- long
-
getLastModified
Description copied from interface:TimeoutConstrainedURLHandlerReturns the last modified timestamp of the resource accessible at the passedurl.Please use
TimeoutConstrainedURLHandler.getURLInfo(URL, TimeoutConstraint)if more one information about theurlis needed- Specified by:
getLastModifiedin interfaceTimeoutConstrainedURLHandler- Parameters:
url- The URL to accesstimeoutConstraint- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- long
-
getURLInfo
Description copied from interface:TimeoutConstrainedURLHandlerReturns theURLHandler.URLInfoextracted from the given url, orURLHandler.UNAVAILABLEwhen the url is not reachable. Never returns null.- Specified by:
getURLInfoin interfaceTimeoutConstrainedURLHandler- 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
-
getCharSetFromContentType
Extract the charset from the Content-Type header string, or default to ISO-8859-1 as per rfc2616-sec3.html#sec3.7.1 .- Parameters:
contentType- the Content-Type header string- Returns:
- the charset as specified in the content type, or ISO-8859-1 if unspecified.
-
openStream
- Specified by:
openStreamin interfaceURLHandler- Parameters:
url- ditto- Returns:
- InputStream
- Throws:
IOException- if something goes wrong
-
openStream
Description copied from interface:TimeoutConstrainedURLHandlerOpens and returns anInputStreamto the passedurl.- Specified by:
openStreamin interfaceTimeoutConstrainedURLHandler- 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
-
download
- Specified by:
downloadin interfaceURLHandler- Parameters:
src- URLdest- Filel- CopyProgressListener- Throws:
IOException- if something goes wrong
-
download
public void download(URL src, File dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) throws IOException Description copied from interface:TimeoutConstrainedURLHandlerDownloads the resource available atsrcto the targetdest- Specified by:
downloadin interfaceTimeoutConstrainedURLHandler- 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
-
upload
- Specified by:
uploadin interfaceURLHandler- Parameters:
source- Filedest- URLl- CopyProgressListener- Throws:
IOException- if something goes wrong
-
upload
public void upload(File src, URL dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) throws IOException Description copied from interface:TimeoutConstrainedURLHandler- Specified by:
uploadin interfaceTimeoutConstrainedURLHandler- 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
-