Class BadResource

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ResourceFactory

    class BadResource
    extends URLResource
    Bad Resource. A Resource that is returned for a bade URL. Acts as a resource that does not exist and throws appropriate exceptions.
    • Field Detail

      • _message

        private java.lang.String _message
    • Constructor Detail

      • BadResource

        BadResource​(java.net.URL url,
                    java.lang.String message)
    • Method Detail

      • exists

        public boolean exists()
        Description copied from class: URLResource
        Returns true if the represented resource exists.
        Overrides:
        exists in class URLResource
        Returns:
        true if the represented resource exists.
      • lastModified

        public long lastModified()
        Description copied from class: URLResource
        Returns the last modified time
        Overrides:
        lastModified in class URLResource
        Returns:
        the last modified time as milliseconds since unix epoch
      • isDirectory

        public boolean isDirectory()
        Description copied from class: URLResource
        Returns true if the represented resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.
        Overrides:
        isDirectory in class URLResource
        Returns:
        true if the represented resource is a container/directory. if the resource is not a file, resources ending with "/" are considered directories.
      • length

        public long length()
        Description copied from class: URLResource
        Return the length of the resource
        Overrides:
        length in class URLResource
        Returns:
        the length of the resource
      • getFile

        public java.io.File getFile()
        Description copied from class: URLResource
        Returns an File representing the given resource or NULL if this is not possible.
        Overrides:
        getFile in class URLResource
        Returns:
        an File representing the given resource or NULL if this is not possible.
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Description copied from class: URLResource
        Returns an input stream to the resource. The underlying url connection will be nulled out to prevent re-use.
        Overrides:
        getInputStream in class URLResource
        Returns:
        an input stream to the resource
        Throws:
        java.io.IOException - if unable to open the input stream
      • delete

        public boolean delete()
                       throws java.lang.SecurityException
        Description copied from class: URLResource
        Deletes the given resource
        Overrides:
        delete in class URLResource
        Returns:
        true if resource was found and successfully deleted, false if resource didn't exist or was unable to be deleted.
        Throws:
        java.lang.SecurityException - if unable to delete due to permissions
      • renameTo

        public boolean renameTo​(Resource dest)
                         throws java.lang.SecurityException
        Description copied from class: URLResource
        Rename the given resource
        Overrides:
        renameTo in class URLResource
        Parameters:
        dest - the destination name for the resource
        Returns:
        true if the resource was renamed, false if the resource didn't exist or was unable to be renamed.
        Throws:
        java.lang.SecurityException - if unable to rename due to permissions
      • list

        public java.lang.String[] list()
        Description copied from class: URLResource
        Returns a list of resource names contained in the given resource
        Overrides:
        list in class URLResource
        Returns:
        a list of resource names contained in the given resource, or null. Note: The resource names are not URL encoded.
      • copyTo

        public void copyTo​(java.io.File destination)
                    throws java.io.IOException
        Description copied from class: Resource
        Copy the Resource to the new destination file.

        Will not replace existing destination file.

        Overrides:
        copyTo in class Resource
        Parameters:
        destination - the destination file to create
        Throws:
        java.io.IOException - if unable to copy the resource