Package org.apache.ivy.util.url
Class URLHandlerDispatcher
- java.lang.Object
-
- org.apache.ivy.util.url.URLHandlerDispatcher
-
- All Implemented Interfaces:
URLHandler
public class URLHandlerDispatcher extends java.lang.Object implements URLHandler
This class is used to dispatch downloading requests
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ivy.util.url.URLHandler
URLHandler.URLInfo
-
-
Field Summary
-
Fields inherited from interface org.apache.ivy.util.url.URLHandler
REQUEST_METHOD_GET, REQUEST_METHOD_HEAD, UNAVAILABLE
-
-
Constructor Summary
Constructors Constructor Description URLHandlerDispatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddownload(java.net.URL src, java.io.File dest, CopyProgressListener l)longgetContentLength(java.net.URL url)Returns the length of the target if the given url is reachable, and without error code in case of http urls.longgetContentLength(java.net.URL url, int timeout)Returns the length of the target if the given url is reachable, and without error code in case of http urls.URLHandlergetDefault()URLHandlergetHandler(java.lang.String protocol)longgetLastModified(java.net.URL url)Please prefer getURLInfo when several infos are needed.longgetLastModified(java.net.URL url, int timeout)Please prefer getURLInfo when several infos are needed.URLHandler.URLInfogetURLInfo(java.net.URL url)Returns the URLInfo of the given url or aURLHandler.UNAVAILABLEinstance, if the url is not reachable.URLHandler.URLInfogetURLInfo(java.net.URL url, int timeout)never returns null, return UNAVAILABLE when url is not reachablebooleanisReachable(java.net.URL url)Please prefer getURLInfo when several infos are needed.booleanisReachable(java.net.URL url, int timeout)Please prefer getURLInfo when several infos are needed.java.io.InputStreamopenStream(java.net.URL url)voidsetDefault(URLHandler default1)voidsetDownloader(java.lang.String protocol, URLHandler downloader)voidsetRequestMethod(int requestMethod)voidupload(java.io.File src, java.net.URL dest, CopyProgressListener l)
-
-
-
Method Detail
-
isReachable
public boolean isReachable(java.net.URL url)
Description copied from interface:URLHandlerPlease prefer getURLInfo when several infos are needed.- Specified by:
isReachablein interfaceURLHandler- Parameters:
url- the url to check- Returns:
- true if the target is reachable
-
isReachable
public boolean isReachable(java.net.URL url, int timeout)Description copied from interface:URLHandlerPlease prefer getURLInfo when several infos are needed.- Specified by:
isReachablein interfaceURLHandler- Parameters:
url- the url to check- Returns:
- true if the target is reachable
-
getContentLength
public long getContentLength(java.net.URL url)
Description copied from interface:URLHandlerReturns the length of the target if the given url is reachable, and without error code in case of http urls. Please prefer getURLInfo when several infos are needed.- Specified by:
getContentLengthin interfaceURLHandler- Parameters:
url- the url to check- Returns:
- the length of the target if available, 0 if not reachable
-
getContentLength
public long getContentLength(java.net.URL url, int timeout)Description copied from interface:URLHandlerReturns the length of the target if the given url is reachable, and without error code in case of http urls.- Specified by:
getContentLengthin interfaceURLHandler- Parameters:
url- the url to checktimeout- the maximum time before considering an url is not reachable a timeout of zero indicates no timeout- Returns:
- the length of the target if available, 0 if not reachable
-
getLastModified
public long getLastModified(java.net.URL url)
Description copied from interface:URLHandlerPlease prefer getURLInfo when several infos are needed.- Specified by:
getLastModifiedin interfaceURLHandler- Parameters:
url- the url to check- Returns:
- last modified timestamp of the given url
-
getLastModified
public long getLastModified(java.net.URL url, int timeout)Description copied from interface:URLHandlerPlease prefer getURLInfo when several infos are needed.- Specified by:
getLastModifiedin interfaceURLHandler- Parameters:
url- the url to check- Returns:
- last modified timestamp of the given url
-
getURLInfo
public URLHandler.URLInfo getURLInfo(java.net.URL url)
Description copied from interface:URLHandlerReturns the URLInfo of the given url or aURLHandler.UNAVAILABLEinstance, if the url is not reachable.- Specified by:
getURLInfoin interfaceURLHandler- Parameters:
url- The url from which information is retrieved.- Returns:
- The URLInfo extracted from the given url, or
URLHandler.UNAVAILABLEwhen the url is not available.
-
getURLInfo
public URLHandler.URLInfo getURLInfo(java.net.URL url, int timeout)
Description copied from interface:URLHandlernever returns null, return UNAVAILABLE when url is not reachable- 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 available.
-
openStream
public java.io.InputStream openStream(java.net.URL url) throws java.io.IOException- Specified by:
openStreamin interfaceURLHandler- Throws:
java.io.IOException
-
download
public void download(java.net.URL src, java.io.File dest, CopyProgressListener l) throws java.io.IOException- Specified by:
downloadin interfaceURLHandler- Throws:
java.io.IOException
-
upload
public void upload(java.io.File src, java.net.URL dest, CopyProgressListener l) throws java.io.IOException- Specified by:
uploadin interfaceURLHandler- Throws:
java.io.IOException
-
setRequestMethod
public void setRequestMethod(int requestMethod)
- Specified by:
setRequestMethodin interfaceURLHandler
-
setDownloader
public void setDownloader(java.lang.String protocol, URLHandler downloader)
-
getHandler
public URLHandler getHandler(java.lang.String protocol)
-
getDefault
public URLHandler getDefault()
-
setDefault
public void setDefault(URLHandler default1)
-
-