Class InMemoryFileSystemImpl

  • All Implemented Interfaces:
    org.refcodes.component.Component, org.refcodes.component.Destroyable, FileSystem


    public class InMemoryFileSystemImpl
    extends java.lang.Object
    implements FileSystem
    An in-memory FileSystem using an ConcurrentHashMap for implementation.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable

        org.refcodes.component.Destroyable.DestroyAutomaton
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      FileHandle createFile​(java.lang.String aKey)
      Creates a file (handle) with the given key.
      FileHandle createFile​(java.lang.String aPath, java.lang.String aName)
      Creates a file (handle) with the given path and name.
      void deleteFile​(FileHandle aFileHandle)
      Deletes a file (handle) from the file system.
      void destroy​()
      java.io.InputStream fromFile​(FileHandle aFromFileHandle)
      An input stream is being provided from which the data of the file (handle) may be read.
      void fromFile​(FileHandle aFromFileHandle, java.io.File aToFile)
      The data contained in the given file (handle) is written to the provided file.
      void fromFile​(FileHandle aFromFileHandle, java.io.OutputStream aOutputStream)
      The data contained in the given file (handle) is written to the provided output stream.
      FileHandle getFileHandle​(java.lang.String aKey)
      Gets a file (handle) with the given key from the file system.
      FileHandle getFileHandle​(java.lang.String aPath, java.lang.String aName)
      Gets a file (handle) with the given path and name from the file system.
      java.util.List<FileHandle> getFileHandles​(java.lang.String aPath, boolean isRecursively)
      With the behavior of the FileSystem.hasFiles(String, boolean) method, all file (handle)s found for the path are returned.
      boolean hasFile​(java.lang.String aKey)
      Tests whether the file system knows a file (handle) with the given key.
      boolean hasFile​(java.lang.String aPath, java.lang.String aName)
      Tests whether the file system knows a file (handle) with the given path and name.
      boolean hasFile​(FileHandle aFileHandle)
      Returns true in case the given file (handle) exists.
      boolean hasFiles​(java.lang.String aPath, boolean isRecursively)
      Determines whether there is any file (handle)s found for the given path.
      FileHandle moveFile​(FileHandle aFileHandle, java.lang.String aNewKey)
      Renames the file (handle), it will be accessible via the provided key.
      FileHandle renameFile​(FileHandle aFileHandle, java.lang.String aNewName)
      Renames the file (handle), the name part of the key will be renamed to the new name.
      java.io.OutputStream toFile​(FileHandle aToFileHandle)
      Returns an output stream which may be used to write (or append, in case data did already exist for the file system) data to a file (handle).
      void toFile​(FileHandle aToFileHandle, byte[] aBuffer)
      Data provided by the given buffer is written to the file (handle) (or appended to the file (handle)'s data in case the file (handle) did already contain data).
      void toFile​(FileHandle aToFileHandle, java.io.File aFromFile)
      Data provided by the given input stream is written to the file (handle) (or appended to the file (handle)'s data in case the file (handle) did already contain data).
      void toFile​(FileHandle aToFileHandle, java.io.InputStream aInputStream)
      Data provided by the given input stream is written to the file (handle) (or appended to the file (handle)'s data in case the file (handle) did already contain data).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait