Class FileResource

  • All Implemented Interfaces:
    Resource

    public final class FileResource
    extends Object
    implements Resource
    Score resource located in the file system.
    Since:
    2019-02-23
    Author:
    Pavel Perminov (packpaul@mail.ru)
    • Constructor Detail

      • FileResource

        public FileResource​(File file)
      • FileResource

        public FileResource​(File file,
                            Namespace namespace)
    • Method Detail

      • delete

        public boolean delete()
                       throws IOException
        Description copied from interface: Resource
        Deletes physical resource that this resource points at.
        Specified by:
        delete in interface Resource
        Returns:
        true if successfully deleted or false otherwise.
        Throws:
        IOException - when an error happened during deletion.
      • contains

        public boolean contains​(Resource childResource)
        Description copied from interface: Resource
        Checks if the passed-in resource is a child of this resource.
        Specified by:
        contains in interface Resource
        Parameters:
        childResource - the checked resource.
        Returns:
      • getRelativePath

        public String getRelativePath​(Resource childResource)
        Description copied from interface: Resource
        Returns relative path from this resource to the child one, or null if such path doesn't exist.
        Specified by:
        getRelativePath in interface Resource
        Parameters:
        childResource - child resource of this resource.
        Returns:
      • createRelative

        public Resource createRelative​(String relativePath,
                                       Namespace namespace)
        Description copied from interface: Resource
        Creates a resource relative to this resource.
        Specified by:
        createRelative in interface Resource
        Parameters:
        relativePath - path relative to this resource.
        namespace - name space of the created resource.
        Returns:
      • getNamespace

        public Namespace getNamespace()
        Description copied from interface: Resource
        Returns namespace of current resource.
        Specified by:
        getNamespace in interface Resource
        Returns:
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object