Class FileMap

java.lang.Object
org.moeaframework.analysis.store.fs.FileMap
All Implemented Interfaces:
Defined
Direct Known Subclasses:
HashFileMap, HierarchicalFileMap

public abstract class FileMap extends Object implements Defined
Defines how containers and blobs are mapped to paths on a file system.

Since arbitrary names can be used, certain characters are escaped:

  1. Invalid or reserved characters are escaped by their hex value (e.g., "/" becomes "%2F"). This also includes whitespace characters.
  2. The character "%", if not being used to escape a value, is represented by "%%".
  3. If a filename starts with "." or "~", this prefix is escaped. This serves two purposes. First, it prevents interpreting the file name as a relative path. Second, it reserves the use of hidden files.
  • Constructor Details

    • FileMap

      public FileMap()
      Constructs a file map.
  • Method Details

    • mapBlob

      public Path mapBlob(Schema schema, Path root, Reference reference, String name) throws IOException
      Returns the path to the blob associated with the given reference and name. The default implementation places the blobs directly inside the container mapped by mapContainer(Schema, Path, Reference).
      Parameters:
      schema - the schema defining the structure
      root - the root directory
      reference - the container reference
      name - the blob name
      Returns:
      the blob path
      Throws:
      IOException - if an I/O error occurred
    • updateManifest

      public void updateManifest(Manifest manifest)
      Updates the manifest with information about this file map.
      Parameters:
      manifest - the manifest
    • escapePath

      public static Path escapePath(String filename)
      Returns a file system-safe path for the give file name.
      Parameters:
      filename - the file name
      Returns:
      the file system-safe path