Class OutputterChecked

Object
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 Details

    • createForDirectoryPermissive

      public static OutputterChecked createForDirectoryPermissive(Path pathDirectory, DirectoryCreationParameters directoryCreation, Optional<Logger> logger) throws BindFailedException
      Creates, defaulting to a permissive output-manager in a particular directory.

      Outputs are not recorded.

      Parameters:
      pathDirectory - directory to associate with output-manager
      directoryCreation - 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 BindFailedException
      Creates a bound output-manager from an existing OutputManager with a prefix.
      Parameters:
      prefix - the prefix
      outputEnabled - which outputs are enabled or not
      context - associated output context
      recordedOutputs - if defined, records output-names that are written / not-written in OutputterChecked (but not any sub-directories thereof)
      directoryCreation - 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.
    • changePrefix

      public OutputterChecked changePrefix(DirectoryWithPrefix prefixToAssign) throws BindFailedException
      Creates a OutputterChecked with a changed prefix.

      All other attributes are identical to the OutputterChecked on which this method is called.

      Parameters:
      prefixToAssign - prefix to assign.
      Returns:
      a newly created identical OutputterChecked apart 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

      public OutputWriteSettings getSettings()
      General settings for outputting.
      Returns:
      the settings.
    • getOutputDirectory

      public Path getOutputDirectory()
      The directory into which outputting occurs.
      Returns:
      a path to the directory.
    • makeOutputPath

      public Path makeOutputPath(String suffix)
      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)
      Like makeOutputPath(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 a prefix is defined nor a suffix, 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

      public void assignLogger(Logger logger)
      Assigns a logger to the outputter, which is used to output warnings or messages when outputting.
      Parameters:
      logger - the logger to assign
    • getPrefix

      public DirectoryWithPrefix getPrefix()
      The directory and prefix into which outputting occurs.
      Returns:
      the directory and prefix.
    • getWriters

      public RecordingWriters getWriters()
      The writers associated with this output-manager.
    • getOutputsEnabled

      public MultiLevelOutputEnabled getOutputsEnabled()
      Which outputs are enabled or not enabled.
    • getContext

      public OutputWriteContext getContext()
      General settings for writing outputs.