Class PathPrefixer
Object
org.anchoranalysis.bean.AnchorBean<PathPrefixer>
org.anchoranalysis.io.output.bean.path.prefixer.PathPrefixer
- Direct Known Subclasses:
PathPrefixerAvoidResolve
public abstract class PathPrefixer extends org.anchoranalysis.bean.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 Summary
Constructors Constructor Description PathPrefixer() -
Method Summary
Modifier and Type Method Description abstract DirectoryWithPrefixoutFilePrefix(NamedPath path, Optional<String> experimentIdentifier, PathPrefixerContext context)Provides a prefix which can be prepended to all output files.protected PathresolvePath(String pathToResolve)LikeresolvePath(Path)but accepts a String as the path.protected PathresolvePath(Path pathToResolve)Converts a relative-path to an absolute-path (relative to the file-path associated with this current bean)abstract DirectoryWithPrefixrootDirectoryPrefix(Optional<String> experimentIdentifier, PathPrefixerContext context)Provides a prefix that becomes the root-folder.
-
Constructor Details
-
PathPrefixer
public PathPrefixer()
-
-
Method Details
-
outFilePrefix
public abstract DirectoryWithPrefix outFilePrefix(NamedPath path, Optional<String> experimentIdentifier, PathPrefixerContext context) throws PathPrefixerExceptionProvides 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 fromexperimentIdentifier- 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 PathPrefixerExceptionProvides 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
LikeresolvePath(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
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)
-