Class FileSystemDataStore

java.lang.Object
org.moeaframework.analysis.store.fs.FileSystemDataStore
All Implemented Interfaces:
DataStore

public class FileSystemDataStore extends Object implements DataStore
Data store backed by the local file system. If the data store already exists, the settings are loaded from a manifest file and arguments passed to the constructor are ignored.

The layout of containers and blobs on the file system are managed by a FileMap, which defaults to HierarchicalFileMap if not specified.

  • Constructor Details

    • FileSystemDataStore

      public FileSystemDataStore(File root)
      Constructs a default file system data store at the specified directory.
      Parameters:
      root - the root directory
      Throws:
      DataStoreException - if an error occurred accessing the data store
    • FileSystemDataStore

      public FileSystemDataStore(Path root)
      Constructs a default file system data store at the specified directory.
      Parameters:
      root - the root directory
      Throws:
      DataStoreException - if an error occurred accessing the data store
    • FileSystemDataStore

      public FileSystemDataStore(File root, FileMap fileMap)
      Constructs a default file system data store at the specified directory.
      Parameters:
      root - the root directory
      fileMap - the file map used when creating a new data store; otherwise the map is read from the manifest
      Throws:
      DataStoreException - if an error occurred accessing the data store
    • FileSystemDataStore

      public FileSystemDataStore(Path root, FileMap fileMap)
      Constructs a hierarchical file system data store at the specified directory.
      Parameters:
      root - the root directory
      fileMap - the file map used when creating a new data store; otherwise the map is read from the manifest
      Throws:
      DataStoreException - if an error occurred accessing the data store
  • Method Details

    • getContainer

      public Container getContainer(Reference key)
      Description copied from interface: DataStore
      Returns the container for the given reference. A container is always returned, though this does not imply the underlying storage exists or has been provisioned.
      Specified by:
      getContainer in interface DataStore
      Parameters:
      key - the data reference
      Returns:
      the container
    • streamContainers

      public Stream<Container> streamContainers() throws DataStoreException
      Description copied from interface: DataStore
      Returns a stream of all containers, excluding the root container, in this data store. The caller must close the stream when finished.
      Specified by:
      streamContainers in interface DataStore
      Returns:
      a stream of containers
      Throws:
      DataStoreException - if an error occurred accessing the data store
    • getURI

      public URI getURI()
      Description copied from interface: DataStore
      Returns the URI for this data store, which can be used with DataStoreFactory.getDataStore(java.net.URI).
      Specified by:
      getURI in interface DataStore
      Returns:
      the URI
    • getIntent

      public Intent getIntent() throws DataStoreException
      Description copied from interface: DataStore
      Returns the application intent that specifies what operations are valid against a data store.
      Specified by:
      getIntent in interface DataStore
      Returns:
      the application intent
      Throws:
      DataStoreException - if an error occurred accessing the data store
    • setIntent

      public void setIntent(Intent intent) throws DataStoreException
      Description copied from interface: DataStore
      Sets the application intent that specifies what operations are valid against a data store.
      Specified by:
      setIntent in interface DataStore
      Parameters:
      intent - the application intent
      Throws:
      DataStoreException - if an error occurred accessing the data store
    • exists

      public boolean exists() throws DataStoreException
      Description copied from interface: DataStore
      Returns true if the underlying, physical data store exists.
      Specified by:
      exists in interface DataStore
      Returns:
      true if the data store exists; false otherwise
      Throws:
      DataStoreException - if an error occurred accessing the data store
    • delete

      public boolean delete() throws DataStoreException
      Description copied from interface: DataStore
      Deletes this data store if it exists, including all containers and blobs contained within.
      Specified by:
      delete in interface DataStore
      Returns:
      true if the data store was deleted; false otherwise
      Throws:
      DataStoreException - if an error occurred accessing the data store
    • create

      public void create() throws DataStoreException
      Creates the underlying, physical data store. Data stores are automatically created when writing a blob, so an explicit call to create is not required.
      Throws:
      DataStoreException - if an error occurred accessing the data store