Interface TimeoutConstrainedURLHandler

    • Method Detail

      • isReachable

        boolean isReachable​(java.net.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​(java.net.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​(java.net.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​(java.net.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

        java.io.InputStream openStream​(java.net.URL url,
                                       TimeoutConstraint timeoutConstraint)
                                throws java.io.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:
        java.io.IOException - if something goes wrong
        Since:
        2.5
      • download

        void download​(java.net.URL src,
                      java.io.File dest,
                      CopyProgressListener listener,
                      TimeoutConstraint timeoutConstraint)
               throws java.io.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:
        java.io.IOException - if something goes wrong
        Since:
        2.5
      • upload

        void upload​(java.io.File src,
                    java.net.URL dest,
                    CopyProgressListener listener,
                    TimeoutConstraint timeoutConstraint)
             throws java.io.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:
        java.io.IOException - if something goes wrong
        Since:
        2.5