Class OutputSequenceFactory<T>
Object
OutputSequenceFactory<T>
- Type Parameters:
T
- element-type for generator (that can also be iterated over)
Creates and starts an output-seqience with a particular generator and context.
This usually occurs in a subdirectory (relative to outputter
, but not necessarily.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionOutputSequenceFactory
(Generator<T> generator, OutputterChecked outputter) Creates a newOutputSequenceFactory
instance. -
Method Summary
Modifier and TypeMethodDescriptionWrites elements todirectory
, with an incrementing integer in the filename.incrementingByOneCurrentDirectory
(String outputName, String prefix, int numberDigits) Writes elements to the current directory, with an incrementing integer in the filename.void
incrementingByOneStream
(OutputPatternIntegerSuffix pattern, Stream<T> stream) Writes file for each element in a stream with an incrementing integer sequence in the outputted file-name.Writes elements (indexed by integers) todirectory
, without any order in the sequence.withoutOrder
(OutputPatternStringSuffix pattern) Writes elements (indexed by strings) todirectory
, without any order in the sequence.withoutOrderCurrentDirectory
(String outputName) Writes elements (indexed by strings) to the current directory, without any order in the sequence.
-
Constructor Details
-
OutputSequenceFactory
Creates a newOutputSequenceFactory
instance.- Parameters:
generator
- The generator to be repeatedly called for writing each element in the sequence.outputter
- The root directory where writing occurs to, often adding a subdirectory for the sequence.
-
-
Method Details
-
incrementingByOne
public OutputSequenceIncrementing<T> incrementingByOne(OutputPatternIntegerSuffix pattern) throws OutputWriteFailedException Writes elements todirectory
, with an incrementing integer in the filename.The integer in the filename starts at 0.
The eventual filename written becomes
$prefix$index.$extension
.- Parameters:
pattern
- how the output of the sequence looks on the file-system.- Returns:
- a newly created sequence
- Throws:
OutputWriteFailedException
- if any outputting cannot be successfully completed.
-
incrementingByOneCurrentDirectory
public OutputSequenceIncrementing<T> incrementingByOneCurrentDirectory(String outputName, String prefix, int numberDigits) throws OutputWriteFailedException Writes elements to the current directory, with an incrementing integer in the filename.The integer in the filename starts at 0.
The eventual filename written becomes
$prefix$index.$extension
.- Parameters:
outputName
- the associated output-nameprefix
- a prefix to include before each filename that is outputted.numberDigits
- the number of digits (adding trailing zeros) for the integer part of the output-name.- Returns:
- a newly created sequence
- Throws:
OutputWriteFailedException
- if any outputting cannot be successfully completed.
-
indexedWithInteger
public OutputSequenceIndexed<T,Integer> indexedWithInteger(OutputPatternIntegerSuffix pattern) throws OutputWriteFailedException Writes elements (indexed by integers) todirectory
, without any order in the sequence.Each index must be unique.
The eventual filename written becomes
$prefix$index.$extension
.- Parameters:
pattern
- how the output of the sequence looks on the file-system.- Returns:
- a newly created sequence
- Throws:
OutputWriteFailedException
- if any outputting cannot be successfully completed.
-
withoutOrder
public OutputSequenceIndexed<T,String> withoutOrder(OutputPatternStringSuffix pattern) throws OutputWriteFailedException Writes elements (indexed by strings) todirectory
, without any order in the sequence.Each index must be unique.
The eventual filename written becomes
$prefix$index.$extension
.- Parameters:
pattern
- how the output of the sequence looks on the file-system.- Returns:
- a newly created sequence
- Throws:
OutputWriteFailedException
- if any outputting cannot be successfully completed.
-
withoutOrderCurrentDirectory
public OutputSequenceIndexed<T,String> withoutOrderCurrentDirectory(String outputName) throws OutputWriteFailedException Writes elements (indexed by strings) to the current directory, without any order in the sequence.Each index must be unique.
The eventual filename written becomes
$index.$extension
without any prefix or suffix.- Parameters:
outputName
- the output-name used in rules to determine if the output is enabled or not.- Returns:
- a newly created sequence
- Throws:
OutputWriteFailedException
- if any outputting cannot be successfully completed.
-
incrementingByOneStream
public void incrementingByOneStream(OutputPatternIntegerSuffix pattern, Stream<T> stream) throws OutputWriteFailedException Writes file for each element in a stream with an incrementing integer sequence in the outputted file-name.The integer in the filename starts at 0.
- Parameters:
pattern
- how the output of the sequence looks on the file-system.stream
- the items to generate separate files- Throws:
OutputWriteFailedException
- if any output fails to be written.
-