public abstract class AbstractRecordFormatter extends Object implements DataFormat.DataFormatter
Constructor and Description |
---|
AbstractRecordFormatter() |
Modifier and Type | Method and Description |
---|---|
void |
bindInput(SteppableRecordValued source)
Simple implementation which passes an input port buffer
to
bindInputFields(RecordValued) . |
protected abstract void |
bindInputFields(RecordValued source)
Provides the buffer holding input data to be formatted.
|
abstract void |
close()
Called to signal that writing is complete.
|
protected abstract void |
formatRecord()
Called to write a formatted record.
|
protected abstract void |
initialize(ByteSink sink,
WriteMode mode)
Prepares the formatter for writing to the provided sink.
|
void |
writeData(ByteSink sink,
WriteMode mode)
Simple implementation of a control loop formatting records.
|
protected abstract void bindInputFields(RecordValued source)
source
- a record valued container which will hold
the current value to be formattedpublic final void bindInput(SteppableRecordValued source)
bindInputFields(RecordValued)
.bindInput
in interface DataFormat.DataFormatter
source
- the input port providing recordsprotected abstract void initialize(ByteSink sink, WriteMode mode) throws IOException
#bindInput(RecordInput)
has been called, but before formatRecord()
is called.
This method is always called, even if the input has no data.
sink
- the target to which data is writtenmode
- how an existing sink should be handledIOException
- if an I/O error occursprotected abstract void formatRecord() throws IOException
bindInputFields(RecordValued)
and write it to the sink passed to initialize(ByteSink, WriteMode)
.
This method is called repeatedly while the record source still has data.
IOException
- if an I/O error occurs while writing the recordpublic final void writeData(ByteSink sink, WriteMode mode)
initialize(ByteSink, WriteMode)
.
If successfully initialized, it then iterates over the previously bound input,
calling formatRecord()
for each record on the port.writeData
in interface DataFormat.DataFormatter
sink
- the data sink to which formatted records
are to be writtenmode
- the access mode for the writepublic abstract void close()
bindInputFields(RecordValued)
has returned
successfully, it is guaranteed that this method
will be called, even if errors occur.
This method is called once,
after the last call to formatRecord()
Any allocated resources which need to be released should be
handled within the implementation of this method.
close
in interface DataFormat.DataFormatter
Copyright © 2020 Actian Corporation. All rights reserved.