public class DirectoryWithPrefix extends Object implements PathCreator
Constructor and Description |
---|
DirectoryWithPrefix(Path folderPath) |
DirectoryWithPrefix(Path directory,
String prefix,
String delimiter) |
Modifier and Type | Method and Description |
---|---|
Path |
asPath(boolean includeDelimeter)
A path that combines the
directory and fileNamePrefix and delimiter . |
Path |
getDirectory() |
Path |
makePathAbsolute(Optional<String> suffix,
Optional<String> extension,
String fallbackSuffix)
Generates a full path, given the final part (suffix) of a path.
|
Path |
makePathRelative(Path fullPath)
Extracts a relative-file path, given the final part (suffix) of a path.
|
String |
prefixWithDelimeter() |
void |
setDelimiter(String delimiter)
Added between
prefix and the filename, if the filename is defined. |
void |
setDirectory(Path folderPath) |
void |
setPrefix(String prefix)
Always prepended to outputted filenames.
|
public DirectoryWithPrefix(Path folderPath)
public void setDirectory(Path folderPath)
public Path asPath(boolean includeDelimeter)
directory
and fileNamePrefix
and delimiter
.includeDelimeter
- if true, the delimeter is included in the combined prefix.public String prefixWithDelimeter()
public Path makePathAbsolute(Optional<String> suffix, Optional<String> extension, String fallbackSuffix)
PathCreator
All sub-directories are created if needed to ensure it's possible to write to the fullPath.
makePathAbsolute
in interface PathCreator
suffix
- the final part of the path, to be added to the prefixextension
- a file extension (without a leading string)fallbackSuffix
- if neither a prefix
is defined nor a suffix
, then this
provides a suffix to use so a file isn't only an extension.public Path makePathRelative(Path fullPath)
PathCreator
The path will be relative to the underlying root directory
.
This relative-path includes any filename-prefix added by the DirectoryWithPrefix
.
makePathRelative
in interface PathCreator
fullPath
- the final part of the path, to be added to the prefixpublic Path getDirectory()
public void setPrefix(String prefix)
public void setDelimiter(String delimiter)
prefix
and the filename, if the filename is defined.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.