Interface TimeoutConstrainedURLHandler

All Superinterfaces:
URLHandler
All Known Implementing Classes:
BasicURLHandler, HttpClientHandler, URLHandlerDispatcher

public interface TimeoutConstrainedURLHandler extends URLHandler
A enhanced version of URLHandler which respects TimeoutConstraints on the operations dealing with download, upload, reachability checks etc...
  • Method Details

    • isReachable

      boolean isReachable(URL url, TimeoutConstraint timeoutConstraint)
      Returns true if the passed URL is reachable. Else returns false. Uses the passed timeoutConstraint for determining the connectivity to the URL.

      Please use getURLInfo(URL, TimeoutConstraint) if more one information about the url is needed

      Parameters:
      url - The URL to access
      timeoutConstraint - The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific
      Returns:
      boolean
      Since:
      2.5
    • getContentLength

      long getContentLength(URL url, TimeoutConstraint timeoutConstraint)
      Returns the number of bytes of data that's available for the resource at the passed url. Returns 0 if the passed url isn't reachable
      Parameters:
      url - The URL to access
      timeoutConstraint - The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific
      Returns:
      long
      Since:
      2.5
    • getLastModified

      long getLastModified(URL url, TimeoutConstraint timeoutConstraint)
      Returns the last modified timestamp of the resource accessible at the passed url.

      Please use getURLInfo(URL, TimeoutConstraint) if more one information about the url is needed

      Parameters:
      url - The URL to access
      timeoutConstraint - The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific
      Returns:
      long
      Since:
      2.5
    • getURLInfo

      URLHandler.URLInfo getURLInfo(URL url, TimeoutConstraint timeoutConstraint)
      Returns the URLHandler.URLInfo extracted from the given url, or URLHandler.UNAVAILABLE when the url is not reachable. Never returns null.
      Parameters:
      url - The URL for which the information is to be retrieved
      timeoutConstraint - The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific
      Returns:
      URLInfo
      Since:
      2.5
    • openStream

      InputStream openStream(URL url, TimeoutConstraint timeoutConstraint) throws IOException
      Opens and returns an InputStream to the passed url.
      Parameters:
      url - The URL to which an InputStream has to be opened
      timeoutConstraint - 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 at src to the target dest
      Parameters:
      src - The source URL to download the resource from
      dest - The destination File to download the resource to
      listener - The listener that will be notified of the download progress
      timeoutConstraint - 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
      Uploads the src File to the target dest URL
      Parameters:
      src - The source File to upload
      dest - The target URL where the File has to be uploaded
      listener - The listener that will be notified of the upload progress
      timeoutConstraint - The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific
      Throws:
      IOException - if something goes wrong
      Since:
      2.5