public interface DataVisitor
DataVisitor
defines protocol of serial access to the data
using Visitor pattern. It allows data provider with complicated data storage
effectively give away data to external data consumer.
Specifically, DataVisitor
allows data provider to take proper
synchronization locks only once per large data block (and not per visited entity)
and save on navigation through data storage by calculating and caching locally
required references and indices.
Therefore, the implementor of DataVisitor
must perform its operations
quickly without need for synchronization and prolonged external actions for each step.
If data consumer in its turn requires synchronized access or is otherwise slow,
then it should accept DataIterator
as a source of data and use
intermediate data buffer (DataBuffer
or equivalent).
The DataVisitor
visits all available data records and for each record
it visits all fields in their serial order (see DataRecord
).
The corresponding state diagram is shown below (note that the number and types of
visited fields exactly matches number and types of the fields in the current record):
+-----> [Ready] | | | 1 visitRecord | | | V | +--> [Visiting Int] | | | | +-------* visitIntField | | | V | +--> [Visiting Obj] | | | | +-------* visitObjField | | +----------+NOTE: if visiting is ever aborted in a state different from [Ready], then behavior of both parties (data visitor and data provider) is undefined.
AbstractRecordSink
or RecordBuffer
as a high-performance implementation of it. New code is also discouraged from using this
interface unless it is need for interoperability with legacy code. Various legacy APIs
will be gradually migrated to NG interfaces and classes.Modifier and Type | Field and Description |
---|---|
static DataVisitor |
VOID |
Modifier and Type | Method and Description |
---|---|
boolean |
hasCapacity()
Returns whether visitor has capacity to efficiently visit next record.
|
void |
visitIntField(DataIntField field,
int value)
Visits next Int-field within current record.
|
void |
visitObjField(DataObjField field,
Object value)
Visits next Obj-field within current record.
|
void |
visitRecord(DataRecord record,
int cipher,
String symbol)
Visits next record.
|
static final DataVisitor VOID
boolean hasCapacity()
NOTE: data visitor must process all data that is passed to it via visitXXX calls no matter whether it has capacity to do it efficiently.
void visitRecord(DataRecord record, int cipher, String symbol)
IllegalStateException
- if visitor is not in [Ready] state.void visitIntField(DataIntField field, int value)
IllegalStateException
- if visitor is not in a state to visit specified field.void visitObjField(DataObjField field, Object value)
IllegalStateException
- if visitor is not in a state to visit specified field.Copyright © 2002–2025 Devexperts LLC. All rights reserved.