Package org.apache.ivy.util.url
Interface URLHandler
-
- All Known Implementing Classes:
AbstractURLHandler,BasicURLHandler,HttpClientHandler,URLHandlerDispatcher
public interface URLHandlerThis interface is responsible for handling some URL manipulation (stream opening, downloading, check reachability, ...).
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classURLHandler.URLInfo
-
Field Summary
Fields Modifier and Type Field Description static intREQUEST_METHOD_GETUsing the slower REQUEST method for getting the basic URL infos.static intREQUEST_METHOD_HEADUsing the faster HEAD method for getting the basic URL infos.static URLHandler.URLInfoUNAVAILABLE
-
Method Summary
All Methods Instance Methods Abstract 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.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 aUNAVAILABLEinstance, 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)voidsetRequestMethod(int requestMethod)voidupload(java.io.File src, java.net.URL dest, CopyProgressListener l)
-
-
-
Field Detail
-
REQUEST_METHOD_GET
static final int REQUEST_METHOD_GET
Using the slower REQUEST method for getting the basic URL infos. Use this when getting errors behind a problematic/special proxy or firewall chain.- See Also:
- Constant Field Values
-
REQUEST_METHOD_HEAD
static final int REQUEST_METHOD_HEAD
Using the faster HEAD method for getting the basic URL infos. Works for most common networks.- See Also:
- Constant Field Values
-
UNAVAILABLE
static final URLHandler.URLInfo UNAVAILABLE
-
-
Method Detail
-
isReachable
boolean isReachable(java.net.URL url)
Please prefer getURLInfo when several infos are needed.- Parameters:
url- the url to check- Returns:
- true if the target is reachable
-
isReachable
boolean isReachable(java.net.URL url, int timeout)Please prefer getURLInfo when several infos are needed.- Parameters:
url- the url to check- Returns:
- true if the target is reachable
-
getContentLength
long getContentLength(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. Please prefer getURLInfo when several infos are needed.- Parameters:
url- the url to check- Returns:
- the length of the target if available, 0 if not reachable
-
getContentLength
long getContentLength(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.- 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
long getLastModified(java.net.URL url)
Please prefer getURLInfo when several infos are needed.- Parameters:
url- the url to check- Returns:
- last modified timestamp of the given url
-
getLastModified
long getLastModified(java.net.URL url, int timeout)Please prefer getURLInfo when several infos are needed.- Parameters:
url- the url to check- Returns:
- last modified timestamp of the given url
-
getURLInfo
URLHandler.URLInfo getURLInfo(java.net.URL url)
Returns the URLInfo of the given url or aUNAVAILABLEinstance, if the url is not reachable.- Parameters:
url- The url from which information is retrieved.- Returns:
- The URLInfo extracted from the given url, or
UNAVAILABLEwhen the url is not available.
-
getURLInfo
URLHandler.URLInfo getURLInfo(java.net.URL url, int timeout)
never returns null, return UNAVAILABLE when url is not reachable- Parameters:
url- The url from which information is retrieved.timeout- The timeout in milliseconds.- Returns:
- The URLInfo extracted from the given url, or
UNAVAILABLEwhen the url is not available.
-
openStream
java.io.InputStream openStream(java.net.URL url) throws java.io.IOException- Throws:
java.io.IOException
-
download
void download(java.net.URL src, java.io.File dest, CopyProgressListener l) throws java.io.IOException- Throws:
java.io.IOException
-
upload
void upload(java.io.File src, java.net.URL dest, CopyProgressListener l) throws java.io.IOException- Throws:
java.io.IOException
-
setRequestMethod
void setRequestMethod(int requestMethod)
-
-