Class InMemoryFileSystem

java.lang.Object
org.refcodes.filesystem.InMemoryFileSystem
All Implemented Interfaces:
org.refcodes.component.Component, org.refcodes.component.Destroyable, FileSystem

public class InMemoryFileSystem extends 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
  • Field Summary

    Fields inherited from interface org.refcodes.filesystem.FileSystem

    PATH_DELIMITER
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an in-memory FileSystem.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a file (handle) with the given key.
    createFile(String aPath, 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
    fromFile(FileHandle aFromFileHandle)
    An input stream is being provided from which the data of the file (handle) may be read.
    void
    fromFile(FileHandle aFromFileHandle, File aToFile)
    The data contained in the given file (handle) is written to the provided file.
    void
    fromFile(FileHandle aFromFileHandle, OutputStream aOutputStream)
    The data contained in the given file (handle) is written to the provided output stream.
    Gets a file (handle) with the given key from the file system.
    getFileHandle(String aPath, String aName)
    Gets a file (handle) with the given path and name from the file system.
    getFileHandles(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
    Tests whether the file system knows a file (handle) with the given key.
    boolean
    hasFile(String aPath, 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(String aPath, boolean isRecursively)
    Determines whether there is any file (handle)s found for the given path.
    moveFile(FileHandle aFileHandle, String aNewKey)
    Renames the file (handle), it will be accessible via the provided key.
    renameFile(FileHandle aFileHandle, String aNewName)
    Renames the file (handle), the name part of the key will be renamed to the new name.
    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, 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, 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