Class AbstractReadOnlyFile

  • All Implemented Interfaces:
    File, Resource
    Direct Known Subclasses:
    ClassPathFile

    public abstract class AbstractReadOnlyFile
    extends java.lang.Object
    implements File
    Abstract base class for read-only File implementations that are not contained in any parent Folder.
    • Constructor Detail

      • AbstractReadOnlyFile

        public AbstractReadOnlyFile()
    • Method Detail

      • getParent

        public Folder getParent()
        Description copied from interface: Resource
        Returns the parent folder of the resource or null if this is the root folder.
        Specified by:
        getParent in interface Resource
        Returns:
        the parent folder or null
      • delete

        public void delete()
        Description copied from interface: Resource
        Delete the current resource (and any children). If this resource does not exist then no operation is performed.
        Specified by:
        delete in interface Resource
      • exists

        public boolean exists()
        Description copied from interface: Resource
        Returns true if the resource exists in the underlying store.
        Specified by:
        exists in interface Resource
        Returns:
        true if the resource exists.
      • createIfMissing

        public void createIfMissing()
        Description copied from interface: Resource
        Recursively creates an empty representation of this resource and all parents. Calling this method on an existing resource has not effect.
        Specified by:
        createIfMissing in interface Resource
      • moveTo

        public File moveTo​(Folder folder)
        Description copied from interface: Resource
        Move this resource to the specified folder. Any duplicate Files will be replaced (existing Folder resources will be merged). If the resource does not exist a ResourceDoesNotExistException is thrown.
        Specified by:
        moveTo in interface File
        Specified by:
        moveTo in interface Resource
        Parameters:
        folder - the folder to move the resource to
        Returns:
        a new resource (the current resource will no longer exist
      • copyTo

        public File copyTo​(Folder folder)
        Description copied from interface: Resource
        Recursively copy this resource to the specified folder. Any duplicate Files will be replaced (existing Folder resources will be merged). If the resource does not exist a ResourceDoesNotExistException is thrown.
        Specified by:
        copyTo in interface File
        Specified by:
        copyTo in interface Resource
        Parameters:
        folder - the folder to copy the resource to
        Returns:
        a new resource (the current resource will no longer exist
      • rename

        public File rename​(java.lang.String name)
        Description copied from interface: Resource
        Rename the current resource. The rename operation cannot be used not move the resource to a different folder, use the Resource.moveTo(Folder) method to move the resource before renaming if required. Root folders cannot be renamed. If the resource does not exist a ResourceDoesNotExistException is thrown.
        Specified by:
        rename in interface File
        Specified by:
        rename in interface Resource
        Parameters:
        name - the new name of the resource (this must not include any path elements)
        Returns:
        a new resource (the current resource will no longer exist
      • getSize

        public long getSize()
        Description copied from interface: File
        Returns the size in bytes of the virtual file.
        Specified by:
        getSize in interface File
        Returns:
        the size in bytes
      • getLastModified

        public long getLastModified()
        Description copied from interface: Resource
        Gets the time this resource object was last modified. The time is measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970).
        Specified by:
        getLastModified in interface Resource
        Returns:
        the time this resource object was last modified; or 0 if the resource object does not exist, if an I/O error occurred, or if the operation is not supported
      • getContent

        public FileContent getContent()
        Description copied from interface: File
        Provides access to file content. Calling any method on a file that does not exist will cause it to be created.
        Specified by:
        getContent in interface File
        Returns:
        the file content
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from interface: Resource
        Determines if this resource is equal to another object. Any resources that have the same type, path and are stored in the same underlying system are considered equal.
        Specified by:
        equals in interface Resource
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to compare to
        Returns:
        true if the resource is equal to the specified object.
      • getInputStream

        protected abstract java.io.InputStream getInputStream()
        Return the input stream for the contents of the File or null if the file does not exist.
        Returns:
        the InputStream or null