Class OutputterChecked
Object
org.anchoranalysis.io.output.outputter.OutputterChecked
public class OutputterChecked extends Object
A particular directory on the filesystem in which outputting can occur.
Unlike Outputter, exceptions are thrown when operations fail.
Further OutputterCheckeds can be derived in sub-directories or with different
prefixes.
A prefix can be associated with the outputter, which prepends a path (containing possibly both subdirectory and file-name parts) on all outputs.
- Author:
- Owen Feehan
-
Method Summary
Modifier and Type Method Description voidassignLogger(Logger logger)Assigns a logger to the outputter, which is used to output warnings or messages when outputting.OutputterCheckedchangePrefix(DirectoryWithPrefix prefixToAssign)Creates aOutputterCheckedwith a changed prefix.static OutputterCheckedcreateForDirectoryPermissive(Path pathDirectory, DirectoryCreationParameters directoryCreation, Optional<Logger> logger)Creates, defaulting to a permissive output-manager in a particular directory.static OutputterCheckedcreateWithPrefix(DirectoryWithPrefix prefix, MultiLevelOutputEnabled outputEnabled, OutputWriteContext context, Optional<MultiLevelRecordedOutputs> recordedOutputs, DirectoryCreationParameters directoryCreation, Optional<Logger> logger)Creates a bound output-manager from an existingOutputManagerwith a prefix.OutputterCheckedderiveSubdirectory(String subdirectoryName, boolean inheritOutputRulesAndRecording)Derives a bound-output-manager for a (possibly newly created) subdirectory of the existing managerOutputWriteContextgetContext()General settings for writing outputs.PathgetOutputDirectory()The directory into which outputting occurs.MultiLevelOutputEnabledgetOutputsEnabled()Which outputs are enabled or not enabled.DirectoryWithPrefixgetPrefix()The directory and prefix into which outputting occurs.OutputWriteSettingsgetSettings()General settings for outputting.RecordingWritersgetWriters()The writers associated with this output-manager.PathmakeOutputPath(String suffix)Creates a full absolute path that completes the part of the path present in the outputter with an additional suffix.PathmakeOutputPath(Optional<String> suffixWithoutExtension, String extension, String fallbackSuffix)LikemakeOutputPath(String)but additionally adds an extension.
-
Method Details
-
createForDirectoryPermissive
public static OutputterChecked createForDirectoryPermissive(Path pathDirectory, DirectoryCreationParameters directoryCreation, Optional<Logger> logger) throws BindFailedExceptionCreates, defaulting to a permissive output-manager in a particular directory.Outputs are not recorded.
- Parameters:
pathDirectory- directory to associate with output-managerdirectoryCreation- how to create the output directory.logger- logger for warning for information messages when outputting- Returns:
- the created outputter.
- Throws:
BindFailedException- if a directory cannot be created at the intended path.
-
createWithPrefix
public static OutputterChecked createWithPrefix(DirectoryWithPrefix prefix, MultiLevelOutputEnabled outputEnabled, OutputWriteContext context, Optional<MultiLevelRecordedOutputs> recordedOutputs, DirectoryCreationParameters directoryCreation, Optional<Logger> logger) throws BindFailedExceptionCreates a bound output-manager from an existingOutputManagerwith a prefix.- Parameters:
outputEnabled- which outputs are enabled or notprefix- the prefixcontext- associated output contextdirectoryCreation- how to create the output directory.recordedOutputs- if defined, records output-names that are written / not-written inOutputterChecked(but not any sub-directories thereof)logger- logger for warning for information messages when outputting- Returns:
- the created outputter.
- Throws:
BindFailedException- if a directory cannot be created at the intended path.
-
changePrefix
public OutputterChecked changePrefix(DirectoryWithPrefix prefixToAssign) throws BindFailedExceptionCreates aOutputterCheckedwith a changed prefix.All other attributes are identical to the
OutputterCheckedon which this method is called.- Parameters:
prefixToAssign- prefix to assign.- Returns:
- a newly created identical
OutputterCheckedapart from the two aforementioned changes. - Throws:
BindFailedException- if a directory cannot be created at the intended path.
-
deriveSubdirectory
public OutputterChecked deriveSubdirectory(String subdirectoryName, boolean inheritOutputRulesAndRecording)Derives a bound-output-manager for a (possibly newly created) subdirectory of the existing manager- Parameters:
subdirectoryName- the subdirectory-name.inheritOutputRulesAndRecording- if true, the output rules and recording are inherited from the parent directory. if false, they are not, and all outputs are allowed and are unrecorded.- Returns:
- a bound-output-manager for the subdirectory.
-
getSettings
General settings for outputting.- Returns:
- the settings.
-
getOutputDirectory
The directory into which outputting occurs.- Returns:
- a path to the directory.
-
makeOutputPath
Creates a full absolute path that completes the part of the path present in the outputter with an additional suffix.- Parameters:
suffix- the suffix for the path- Returns:
- a newly created absolute path, combining directory, prefix (if it exists) and suffix.
-
makeOutputPath
public Path makeOutputPath(Optional<String> suffixWithoutExtension, String extension, String fallbackSuffix)LikemakeOutputPath(String)but additionally adds an extension.- Parameters:
suffixWithoutExtension- the suffix for the path (without any extension).extension- a file extension (without a leading period).fallbackSuffix- if neither aprefixis defined nor asuffix, then this provides a suffix to use so a file isn't only an extension.- Returns:
- a newly created absolute path, combining directory, prefix (if it exists), suffix and extension.
-
assignLogger
Assigns a logger to the outputter, which is used to output warnings or messages when outputting.- Parameters:
logger- the logger to assign
-
getPrefix
The directory and prefix into which outputting occurs.- Returns:
- the directory and prefix.
-
getWriters
The writers associated with this output-manager. -
getOutputsEnabled
Which outputs are enabled or not enabled. -
getContext
General settings for writing outputs.
-