Interface ResourceFile

  • All Superinterfaces:
    it.tidalwave.util.As, it.tidalwave.role.Composite<ResourceFile,​ResourceFile.Finder>
    All Known Implementing Classes:
    DecoratedResourceFileSupport

    public interface ResourceFile
    extends it.tidalwave.util.As, it.tidalwave.role.Composite<ResourceFile,​ResourceFile.Finder>
    A file backing a Resource. There can be various implementations of this interface: plain files on the local disk, items in a zip file, elements of a repository such as Mercurial or Git, objects stored within a database, etc...
    Author:
    Fabrizio Giudici
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  ResourceFile.Finder
      A ResourceFile.Finder for retrieving children of ResourceFile.
      • Nested classes/interfaces inherited from interface it.tidalwave.util.As

        it.tidalwave.util.As.Type<T extends java.lang.Object>
      • Nested classes/interfaces inherited from interface it.tidalwave.role.Composite

        it.tidalwave.role.Composite.Visitor<T extends java.lang.Object,​R extends java.lang.Object>
    • Field Summary

      • Fields inherited from interface it.tidalwave.role.Composite

        _Composite_, DEFAULT
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      byte[] asBytes()
      Returns the full contents of this file as binary data.
      java.lang.String asText​(java.lang.String encoding)
      Returns the full contents of this file as text.
      void copyTo​(ResourceFile targetFolder)
      Don't use
      ResourceFile createFolder​(java.lang.String name)
      Don't use
      void delete()
      Don't use
      ResourceFileSystem getFileSystem()
      Returns the ResourceFileSystem this file belongs to.
      java.io.InputStream getInputStream()
      Returns an InputStream that allows to read contents of this file.
      java.time.ZonedDateTime getLatestModificationTime()
      Returns the latest modification time of this file.
      java.lang.String getMimeType()
      Returns the MIME type associated to the contents of this file.
      java.lang.String getName()
      Returns the name of this file (it doesn't include the full path).
      ResourceFile getParent()
      Returns the parent of this file.
      ResourcePath getPath()
      Returns the full path of this file.
      boolean isData()
      Returns true whether this file is a plain file.
      boolean isFolder()
      Returns true whether this file is a folder.
      java.io.File toFile()
      FIXME: drop this - it won't work with virtual file systems
      • Methods inherited from interface it.tidalwave.util.As

        as, as, asMany, asMany, maybeAs, maybeAs
      • Methods inherited from interface it.tidalwave.role.Composite

        findChildren
    • Method Detail

      • getName

        @Nonnull
        java.lang.String getName()
        Returns the name of this file (it doesn't include the full path).
        Returns:
        the name of the file
      • getPath

        @Nonnull
        ResourcePath getPath()
        Returns the full path of this file. FIXME: the root object returns "" in place of "/" - this will change in future
        Returns:
        the full path of the file
      • isFolder

        boolean isFolder()
        Returns true whether this file is a folder.
        Returns:
        true for a folder
      • isData

        boolean isData()
        Returns true whether this file is a plain file.
        Returns:
        true for a file
      • getMimeType

        @Nonnull
        java.lang.String getMimeType()
        Returns the MIME type associated to the contents of this file. The value is achieved by querying the web server context.
        Returns:
        the MIME type
      • getInputStream

        @Nonnull
        java.io.InputStream getInputStream()
                                    throws java.io.FileNotFoundException
        Returns an InputStream that allows to read contents of this file.
        Returns:
        the InputStream
        Throws:
        java.io.FileNotFoundException - if the physical data can't be accessed
      • asText

        @Nonnull
        java.lang.String asText​(@Nonnull
                                java.lang.String encoding)
                         throws java.io.IOException
        Returns the full contents of this file as text.
        Parameters:
        encoding - the content encoding
        Returns:
        the contents
        Throws:
        java.io.IOException - if an I/O error occurs
      • asBytes

        @Nonnull
        byte[] asBytes()
                throws java.io.IOException
        Returns the full contents of this file as binary data.
        Returns:
        the contents
        Throws:
        java.io.IOException - if an I/O error occurs
      • getLatestModificationTime

        @Nonnull
        java.time.ZonedDateTime getLatestModificationTime()
        Returns the latest modification time of this file.
        Returns:
        the latest modification time
      • getParent

        ResourceFile getParent()
        Returns the parent of this file. FIXME: make @Nonnull, use Optional
        Returns:
        the parent or null if no parent
      • toFile

        @Nonnull
        java.io.File toFile()
        FIXME: drop this - it won't work with virtual file systems
      • delete

        void delete()
             throws java.io.IOException
        Don't use
        Throws:
        java.io.IOException
      • createFolder

        @Nonnull
        ResourceFile createFolder​(@Nonnull
                                  java.lang.String name)
                           throws java.io.IOException
        Don't use
        Throws:
        java.io.IOException
      • copyTo

        void copyTo​(@Nonnull
                    ResourceFile targetFolder)
             throws java.io.IOException
        Don't use
        Throws:
        java.io.IOException