Class LabelledResultsCSVWriter
Object
LabelledResultsCSVWriter
Allows results to be written to a
FeatureCSVWriter
, possibly adding further processing.- Author:
- Owen Feehan
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FeatureCSVMetadataForOutput
Metadata defining which CSV file to write to, and which headers. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
LabelledResultsCSVWriter
(FeatureCSVMetadataForOutput outputMetadata, FeatureCSVWriterFactory writerCreator, Optional<Consumer<LabelledResultsVector>> consumeAfterAdding) Creates a newLabelledResultsCSVWriter
instance. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
add
(LabelledResultsVector results) Adds a results-element to be written.protected Optional
<FeatureCSVWriter> createWriter
(FeatureCSVMetadata csvMetadata) Creates aCSVWriter
.abstract void
end()
Stops writing the CSV file.protected void
maybeConsumeResults
(LabelledResultsVector results) Consumes theLabelledResultsVector
ifconsumeAfterAdding
is present.abstract void
start()
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) Creates a newLabelledResultsCSVWriter
instance.- Parameters:
outputMetadata
- Metadata defining which CSV file to write to, and which headers.writerCreator
- Creates aFeatureCSVWriter
for writing the non-aggregated feature results.consumeAfterAdding
- After adding aLabelledResultsVector
, this function is also called, if it is defined.
-
-
Method Details
-
start
Starts writing the CSV file.This should be called once, before any calls to
add(LabelledResultsVector)
.- Throws:
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
Stops writing the CSV file.This should be called once, after all calls to
add(LabelledResultsVector)
.- Throws:
OutputWriteFailedException
- if the output file cannot be created.
-
createWriter
protected Optional<FeatureCSVWriter> createWriter(FeatureCSVMetadata csvMetadata) throws OutputWriteFailedException Creates aCSVWriter
.- Parameters:
csvMetadata
- the metadata for the writer.- Returns:
- the newly-created writer, if possible.
- Throws:
OutputWriteFailedException
- if the CSV file cannot be created successfully.
-
maybeConsumeResults
Consumes theLabelledResultsVector
ifconsumeAfterAdding
is present.- Parameters:
results
- the results to maybe consume.
-