Interface Resource

    • Method Detail

      • getParent

        Folder getParent()
        Returns the parent folder of the resource or null if this is the root folder.
        Returns:
        the parent folder or null
        Throws:
        ResourceDoesNotExistException - if this resource no longer exists
      • getName

        java.lang.String getName()
        Returns the name of the resource. This name does not include any path element. Root folders will have an empty string name.
        Returns:
        the name of the resource, for example "file.txt"
        Throws:
        ResourceDoesNotExistException - if this resource no longer exists
      • delete

        void delete()
        Delete the current resource (and any children). If this resource does not exist then no operation is performed.
      • moveTo

        Resource moveTo​(Folder folder)
        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.
        Parameters:
        folder - the folder to move the resource to
        Returns:
        a new resource (the current resource will no longer exist
        Throws:
        ResourceDoesNotExistException - if this resource no longer exists
      • copyTo

        Resource copyTo​(Folder folder)
        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.
        Parameters:
        folder - the folder to copy the resource to
        Returns:
        a new resource (the current resource will no longer exist
        Throws:
        ResourceDoesNotExistException - if this resource no longer exists
      • rename

        Resource rename​(java.lang.String name)
        Rename the current resource. The rename operation cannot be used not move the resource to a different folder, use the 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.
        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
        Throws:
        ResourceExistsException - if a resource already exists with the specified name
      • exists

        boolean exists()
        Returns true if the resource exists in the underlying store.
        Returns:
        true if the resource exists.
      • createIfMissing

        void createIfMissing()
        Recursively creates an empty representation of this resource and all parents. Calling this method on an existing resource has not effect.
      • toString

        java.lang.String toString()
        Returns the complete name of the resource. This name includes path elements. Folders always end in '/'.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the full name of the resource, for example "/folder/file.txt" or "/folder/"
        See Also:
        getName(), toString(ResourceStringFormat), toStringRelativeTo(Folder)
      • toStringRelativeTo

        java.lang.String toStringRelativeTo​(Folder source)
        Returns the the complete name of this resource (including path elements) relative to the specified source folder. The source must be a parent (or grandparent etc) of this resource. If the source is this folder an empty String is returned. The returned value does not include any leading slash, for example: '/a/b/c.txt' relative to '/a/' will return 'b/c.txt'.
        Parameters:
        source - the source folder
        Returns:
        the name
        See Also:
        toString(), toStringRelativeTo(Folder)
      • isRelativeTo

        boolean isRelativeTo​(Folder folder)
        Returns:
        true if the given param folder is relative to comprising folder object, else return false
      • equals

        boolean equals​(java.lang.Object obj)
        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.
        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.
      • getLastModified

        long getLastModified()
        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).
        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
      • isModifiedAfter

        boolean isModifiedAfter​(long n)
      • isModifiedAfter

        boolean isModifiedAfter​(Resource resource)
      • isModifiedBefore

        boolean isModifiedBefore​(long n)
      • isModifiedBefore

        boolean isModifiedBefore​(Resource resource)