RecordBuffer
instead.public class DataBuffer extends Object implements DataConsumer, DataProvider, DataIterator, DataVisitor
DataBuffer
class is an universal buffer for data,
able to receive and retrieve data via all appropriate interfaces and
via random access. It uses cyclic buffers for efficient data storage.
NOTE: the DataBuffer
is not thread-safe;
it is designed to be used in a single-thread mode.
Modifier and Type | Field and Description |
---|---|
static DataBuffer |
VOID
Deprecated.
Many cases in code that use to this object do not need it any more. Double-check first.
If really needed, then use
DataVisitor.VOID ,
DataIterator.VOID ,
DataConsumer.VOID , or
DataListener.VOID . |
Constructor and Description |
---|
DataBuffer()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deprecated.
Clears this data buffer.
|
protected void |
completeIteration()
Deprecated.
Checks and completes ongoing iteration if it has finished current record.
|
protected void |
completeVisit()
Deprecated.
Checks and completes ongoing visit if it has finished current record.
|
protected static void |
copy(Object src,
Object dst,
int head,
int tail,
int length)
Deprecated.
Copies cyclic array buffer from source to destination.
|
protected void |
ensureCapacity(DataRecord record)
Deprecated.
Ensures that this buffer has capacity to visit and store specified record.
|
boolean |
examineData(DataVisitor visitor)
Deprecated.
Examines accumulated data via specified data visitor.
|
void |
examineRecord(int index,
DataVisitor visitor)
Deprecated.
Examines record by its index within this buffer via specivied visitor.
|
DataIterator |
examiningIterator()
Deprecated.
Returns data iterator that examines this data buffer.
|
DataIterator |
examiningIterator(boolean reversed)
Deprecated.
Returns data iterator that examines this data buffer with optional reversal.
|
DataIterator |
examiningIterator(int index,
int last_index)
Deprecated.
Returns data iterator that examines this data buffer in the given range.
|
DataProvider |
examiningProvider()
Deprecated.
|
int |
getCipher()
Deprecated.
Returns cipher for the current record returned by last call to
DataIterator.nextRecord() . |
int |
getCipher(int index)
Deprecated.
Returns cipher of the record by its index within this buffer.
|
int |
getInt(int index,
int int_field_index)
Deprecated.
Returns specified Int-field of the record by its index within this buffer.
|
Object |
getObj(int index,
int obj_field_index)
Deprecated.
Returns specified Obj-field of the record by its index within this buffer.
|
DataRecord |
getRecord(int index)
Deprecated.
Returns record by its index within this buffer.
|
String |
getSymbol()
Deprecated.
Returns symbol for the current record returned by last call to
DataIterator.nextRecord() . |
String |
getSymbol(int index)
Deprecated.
Returns symbol of the record by its index within this buffer.
|
long |
getTime(int index)
Deprecated.
Returns time of the record given by its index within this buffer.
|
protected static int |
growLength(int length,
int size)
Deprecated.
Grows length twice until it is larger than size.
|
boolean |
hasCapacity()
Deprecated.
Returns whether visitor has capacity to efficiently visit next record.
|
boolean |
isEmpty()
Deprecated.
Returns
true if this data buffer has no records. |
int |
nextIntField()
Deprecated.
Returns next Int-field within current record being iterated.
|
Object |
nextObjField()
Deprecated.
Returns next Obj-field within current record being iterated.
|
DataRecord |
nextRecord()
Deprecated.
Returns next record.
|
protected void |
notifyListener()
Deprecated.
Notifies data listener used in
DataProvider part
of this data buffer. |
static boolean |
process(DataIterator iterator,
DataVisitor visitor)
Deprecated.
Use
RecordBuffer.retrieveData(DataVisitor) or
LegacyIteratorUtils.processData(DataIterator, DataVisitor) as last resort. |
void |
processData(DataIterator iterator)
Deprecated.
Processes data from specified data iterator.
|
boolean |
retrieveData(DataVisitor visitor)
Deprecated.
Retrieves accumulated data into specified data visitor.
|
void |
setDataListener(DataListener listener)
Deprecated.
Sets new data listener to receive notifications about data.
|
int |
size()
Deprecated.
Returns number of records in this data buffer.
|
void |
visitIntField(DataIntField field,
int value)
Deprecated.
Visits next Int-field within current record.
|
void |
visitObjField(DataObjField field,
Object value)
Deprecated.
Visits next Obj-field within current record.
|
void |
visitRecord(DataRecord record,
int cipher,
String symbol)
Deprecated.
Visits next record.
|
public static final DataBuffer VOID
DataVisitor.VOID
,
DataIterator.VOID
,
DataConsumer.VOID
, or
DataListener.VOID
.public static boolean process(DataIterator iterator, DataVisitor visitor)
RecordBuffer.retrieveData(DataVisitor)
or
LegacyIteratorUtils.processData(DataIterator, DataVisitor)
as last resort.true
if some data may still remain in
the iterator or false
if all data were processed.public int size()
public boolean isEmpty()
true
if this data buffer has no records.public void clear()
public int getCipher(int index)
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public String getSymbol(int index)
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public DataRecord getRecord(int index)
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public long getTime(int index)
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).IllegalArgumentException
- is the corresponding record has no time.public int getInt(int index, int int_field_index)
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).IndexOutOfBoundsException
- if the int_field_index is out of range
(int_field_index < 0 || int_field_index >= getIntFieldCount()) of corresponding record.public Object getObj(int index, int obj_field_index)
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).IndexOutOfBoundsException
- if the obj_field_index is out of range
(obj_field_index < 0 || obj_field_index >= getObjFieldCount()) of corresponding record.public void examineRecord(int index, DataVisitor visitor)
NOTE: unlike bulk transfer methods, this method does not check
DataVisitor.hasCapacity()
method of specified visitor.
IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public boolean examineData(DataVisitor visitor)
true
if not all accumulated data were examined
or false
if all accumulated data were examined.public DataProvider examiningProvider()
public DataIterator examiningIterator()
NOTE: returned iterator possesses no special protection against concurrent modifications of this buffer and it will fail in unexpected way in such event; it should be used up before any such modifications.
public DataIterator examiningIterator(boolean reversed)
NOTE: returned iterator possesses no special protection against concurrent modifications of this buffer and it will fail in unexpected way in such event; it should be used up before any such modifications.
reversed
- Record order is reversed if it is true
.public DataIterator examiningIterator(int index, int last_index)
index == last_index
then no data is examined.
index < last_index
then data is examined in forward order.
index > last_index
then data is examined in reverse order.
NOTE: returned iterator possesses no special protection against concurrent modifications of this buffer and it will fail in unexpected way in such event; it should be used up before any such modifications.
index
- first index inclusive.last_index
- exclusive.public void processData(DataIterator iterator)
DataConsumer
DataIterator
also implements RecordSource
interface
(RecordBuffer
is such default and high-performance implementation),
since it yields better performance in certain cases and enables some new features that are not supported with
legacy DataIterator
implementations.processData
in interface DataConsumer
public boolean retrieveData(DataVisitor visitor)
DataProvider
true
if some data still remains in the provider
or false
if all accumulated data were retrieved.retrieveData
in interface DataProvider
public void setDataListener(DataListener listener)
DataProvider
null
to set empty data listener (no notifications).
NOTE: if there is accumulated data available, then specified listener will be notified by this method.
setDataListener
in interface DataProvider
public int getCipher()
DataIterator
DataIterator.nextRecord()
.
Returns 0 if not encoded or if no current record is being iterated.getCipher
in interface DataIterator
public String getSymbol()
DataIterator
DataIterator.nextRecord()
.
Returns null if encoded or if no current record is being iterated.getSymbol
in interface DataIterator
public DataRecord nextRecord()
DataIterator
nextRecord
in interface DataIterator
public int nextIntField()
DataIterator
nextIntField
in interface DataIterator
public Object nextObjField()
DataIterator
nextObjField
in interface DataIterator
public boolean hasCapacity()
DataVisitor
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.
hasCapacity
in interface DataVisitor
public void visitRecord(DataRecord record, int cipher, String symbol)
DataVisitor
visitRecord
in interface DataVisitor
public void visitIntField(DataIntField field, int value)
DataVisitor
visitIntField
in interface DataVisitor
public void visitObjField(DataObjField field, Object value)
DataVisitor
visitObjField
in interface DataVisitor
protected void completeIteration()
protected void completeVisit()
protected void notifyListener()
DataProvider
part
of this data buffer. Does not check actual data availability.protected void ensureCapacity(DataRecord record)
protected static int growLength(int length, int size)
Copyright © 2002–2025 Devexperts LLC. All rights reserved.