Interface Resource

  • All Known Implementing Classes:
    FileResource, UrlResource

    public interface Resource
    Score resource abstraction. Its implementation may point to a physical file or a resource in a JAR-file.
    Since:
    2019-02-23
    Author:
    Pavel Perminov (packpaul@mail.ru)
    • Method Detail

      • getInputStream

        InputStream getInputStream()
                            throws IOException
        Returns input stream for the resource.
        Returns:
        Throws:
        IOException - when input stream cannot be provided.
      • getOutputStream

        default OutputStream getOutputStream()
                                      throws IOException
        Returns output stream for the resource if it is writable, null otherwise.
        Returns:
        Throws:
        IOException - when output stream cannot be provided.
      • delete

        default boolean delete()
                        throws IOException
        Deletes physical resource that this resource points at.
        Returns:
        true if successfully deleted or false otherwise.
        Throws:
        IOException - when an error happened during deletion.
      • contains

        default boolean contains​(Resource childResource)
        Checks if the passed-in resource is a child of this resource.
        Parameters:
        childResource - the checked resource.
        Returns:
      • getRelativePath

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

        default Resource createRelative​(Namespace namespace)
                                 throws IOException
        Creates a resource relative to this resource.
        Parameters:
        namespace - name space path relative to this resource.
        Returns:
        Throws:
        IOException - when resource creation failed.
      • createRelative

        default Resource createRelative​(String relativePath)
                                 throws IOException
        Creates a resource relative to this resource.
        Parameters:
        relativePath - path relative to this resource.
        Returns:
        Throws:
        IOException - when resource creation failed.
      • createRelative

        Resource createRelative​(String relativePath,
                                Namespace namespace)
                         throws IOException
        Creates a resource relative to this resource.
        Parameters:
        relativePath - path relative to this resource.
        namespace - name space of the created resource.
        Returns:
        Throws:
        IOException - when resource creation failed.
      • getNamespace

        Namespace getNamespace()
        Returns namespace of current resource.
        Returns: