Direct Known Subclasses:
HomeSubdirectory, PathPrefixerAvoidResolve, Rooted

public abstract class PathPrefixer extends AnchorBean<PathPrefixer>
Base classes for methods to determine an output directory and associated file prefix.

This is derived from an identifier for an experiment, and input paths.

Author:
Owen Feehan
  • Constructor Details

    • PathPrefixer

      public PathPrefixer()
  • Method Details

    • outFilePrefix

      public abstract DirectoryWithPrefix outFilePrefix(NamedPath path, Optional<String> experimentIdentifier, PathPrefixerContext context) throws PathPrefixerException
      Provides a prefix which can be prepended to all output files. The prefix should be an absolute path.
      Parameters:
      path - an input to derive a prefix from
      experimentIdentifier - if defined, an identifier for the experiment, to be included in the directory root.
      context - the context in which prefixing of paths occurs.
      Returns:
      a directory with an associated prefix.
      Throws:
      PathPrefixerException - if unable to successfully determine a prefix.
    • rootDirectoryPrefix

      public abstract DirectoryWithPrefix rootDirectoryPrefix(Optional<String> experimentIdentifier, PathPrefixerContext context) throws PathPrefixerException
      Provides a prefix that becomes the root-folder. The prefix should be an absolute path.
      Parameters:
      experimentIdentifier - if defined, an identifier for the experiment, to be included in the directory root.
      context - the context in which prefixing of paths occurs.
      Returns:
      a directory with an associated prefix.
      Throws:
      PathPrefixerException - if unable to successfully determine a prefix.
    • resolvePath

      protected Path resolvePath(String pathToResolve)
      Like resolvePath(Path) but accepts a String as the path.
      Parameters:
      pathToResolve - input-path that is relative.
      Returns:
      the converted path (relative to the localizedPath of the current file)
    • resolvePath

      protected Path resolvePath(Path pathToResolve)
      Converts a relative-path to an absolute-path (relative to the file-path associated with this current bean)

      If there is no file-path associated with the current bean, then we throw an error if it is a relative path, or otherwise it remains unchanged

      If the pathToResolve is already absolute, then we return it as-is

      Parameters:
      pathToResolve - input-path that is relative.
      Returns:
      the converted path (relative to the localizedPath of the current file)