Class FileResource

java.lang.Object
ru.curs.celesta.score.io.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 Details

    • FileResource

      public FileResource(File file)
    • FileResource

      public FileResource(File file, Namespace namespace)
  • Method Details

    • getInputStream

      public InputStream getInputStream() throws IOException
      Description copied from interface: Resource
      Returns input stream for the resource.
      Specified by:
      getInputStream in interface Resource
      Returns:
      Throws:
      IOException - when input stream cannot be provided.
    • getOutputStream

      public OutputStream getOutputStream() throws IOException
      Description copied from interface: Resource
      Returns output stream for the resource if it is writable, null otherwise.
      Specified by:
      getOutputStream in interface Resource
      Returns:
      Throws:
      IOException - when output stream cannot be provided.
    • 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:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object