Class LabelledResultsCSVWriter
Object
org.anchoranalysis.feature.io.csv.results.LabelledResultsCSVWriter
public abstract class LabelledResultsCSVWriter extends Object
Allows results to be written to a
FeatureCSVWriter, possibly adding further processing.- Author:
- Owen Feehan
-
Field Summary
Fields Modifier and Type Field Description protected FeatureCSVMetadataForOutputoutputMetadataMetadata defining which CSV file to write to, and which headers. -
Constructor Summary
Constructors Modifier Constructor Description protectedLabelledResultsCSVWriter(FeatureCSVMetadataForOutput outputMetadata, FeatureCSVWriterFactory writerCreator, Optional<Consumer<LabelledResultsVector>> consumeAfterAdding) -
Method Summary
Modifier and Type Method Description abstract voidadd(LabelledResultsVector results)Adds a results-element to be written.protected Optional<FeatureCSVWriter>createWriter(FeatureCSVMetadata csvMetadata)Creates aCSVWriter.abstract voidend()Stops writing the CSV file.protected voidmaybeConsumeResults(LabelledResultsVector results)Consumes theLabelledResultsVectorifconsumeAfterAddingis present.abstract voidstart()Starts writing the CSV file.
-
Field Details
-
outputMetadata
Metadata defining which CSV file to write to, and which headers.
-
-
Constructor Details
-
LabelledResultsCSVWriter
protected LabelledResultsCSVWriter(FeatureCSVMetadataForOutput outputMetadata, FeatureCSVWriterFactory writerCreator, Optional<Consumer<LabelledResultsVector>> consumeAfterAdding)
-
-
Method Details
-
start
public abstract void start() throws org.anchoranalysis.io.output.error.OutputWriteFailedExceptionStarts writing the CSV file.This should be called once, before any calls to
add(LabelledResultsVector).- Throws:
org.anchoranalysis.io.output.error.OutputWriteFailedException- if the output file cannot be created.
-
add
Adds a results-element to be written.This should be called once for each set of results to be written.
- Parameters:
results- the results.
-
end
public abstract void end() throws org.anchoranalysis.io.output.error.OutputWriteFailedExceptionStops writing the CSV file.This should be called once, after all calls to
add(LabelledResultsVector).- Throws:
org.anchoranalysis.io.output.error.OutputWriteFailedException- if the output file cannot be created.
-
createWriter
protected Optional<FeatureCSVWriter> createWriter(FeatureCSVMetadata csvMetadata) throws org.anchoranalysis.io.output.error.OutputWriteFailedExceptionCreates aCSVWriter.- Parameters:
csvMetadata- the metadata for the writer.- Returns:
- the newly-created writer, if possible.
- Throws:
org.anchoranalysis.io.output.error.OutputWriteFailedException- if the CSV file cannot be created successfully.
-
maybeConsumeResults
Consumes theLabelledResultsVectorifconsumeAfterAddingis present.- Parameters:
results- the results to maybe consume.
-