Class WriterRouterErrors
Object
org.anchoranalysis.io.output.writer.WriterRouterErrors
public class WriterRouterErrors extends Object
Write data via
ElementWriters to the file system.
Or alternatively write by creating new sub-directories for writing data to.
This class is similar to Writer but:
- exceptions are suppressed and errors are instead reported.
- differences exist around writing sub-folders.
These operations occur in association with the currently bound output manager.
The ElementWriterSupplier interface is used so as to avoid object-creation if an
operation isn't actually written.
Note that a ElementWriter may write more than one file for a given element.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description WriterRouterErrors(Writer delegate, ErrorReporter errorReporter) -
Method Summary
Modifier and Type Method Description Optional<Path>createFilenameForWriting(String outputName, String extension)The path to write a particular output to.Optional<Outputter>createSubdirectory(String outputName, boolean inheritOutputRulesAndRecording)Maybe creates a subdirectory for writing to.<T> voidwrite(String outputName, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element)Writes an element using anElementWriterto the current directory.<T> voidwriteWithIndex(IndexableOutputNameStyle outputNameStyle, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element, String index)Writes an indexed-element using anElementWriterin the current directory.
-
Constructor Details
-
Method Details
-
createSubdirectory
public Optional<Outputter> createSubdirectory(String outputName, boolean inheritOutputRulesAndRecording)Maybe creates a subdirectory for writing to.- Parameters:
outputName- the name of the subdirectory.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:
- an output-manager for the directory if it is allowed, otherwise
Optional.empty().
-
write
public <T> void write(String outputName, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element)Writes an element using anElementWriterto the current directory.- Parameters:
outputName- the name of the subdirectory. This may determine if an output is allowed or not.elementWriter- writes the element to the filesystemelement- the element to write
-
writeWithIndex
public <T> void writeWithIndex(IndexableOutputNameStyle outputNameStyle, ElementWriterSupplier<T> elementWriter, ElementSupplier<T> element, String index)Writes an indexed-element using anElementWriterin the current directory.- Parameters:
outputNameStyle- how to combine a particular output-name with an indexelementWriter- writes the element to the filesystemelement- the element to writeindex- the index
-
createFilenameForWriting
The path to write a particular output to.This is an alternative method to write to the file system rather than using an
ElementWriterandwrite(String, ElementWriterSupplier, ElementSupplier)andwriteWithIndex(IndexableOutputNameStyle, ElementWriterSupplier, ElementSupplier, String).- Parameters:
outputName- the output-name. This is the filename without an extension, and may determine if an output is allowed or not.extension- the extension- Returns:
- the path to write to, if it is allowed, otherwise
Optional.empty().
-