com.devexperts.qd
Class DataBuffer

java.lang.Object
  extended by com.devexperts.qd.DataBuffer
All Implemented Interfaces:
DataConsumer, DataIterator, DataProvider, DataVisitor

Deprecated. Use RecordBuffer instead.

public class DataBuffer
extends java.lang.Object
implements DataConsumer, DataProvider, DataIterator, DataVisitor

The 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.


Field Summary
static DataBuffer VOID
          Deprecated. The instance of DataBuffer that is always empty.
 
Constructor Summary
DataBuffer()
          Deprecated.  
 
Method Summary
 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(java.lang.Object src, java.lang.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.
 java.lang.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.
 java.lang.String getSymbol()
          Deprecated. Returns symbol for the current record returned by last call to DataIterator.nextRecord().
 java.lang.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.
 java.lang.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. Processes data from specified iterator via specified visitor.
 void processData(DataIterator iterator)
          Deprecated. Processes data from specified data iterator.
 void replaceFields(int index, DataBuffer src_buffer, int src_index)
          Deprecated. Used by History implementation - to be reconcidered.
 void replaceFields(int index, RecordCursor cursor)
          Deprecated. Used by History implementation - to be reconcidered.
 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, java.lang.Object value)
          Deprecated. Visits next Obj-field within current record.
 void visitRecord(DataRecord record, int cipher, java.lang.String symbol)
          Deprecated. Visits next record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VOID

public static final DataBuffer VOID
Deprecated. 
The instance of DataBuffer that is always empty.

Constructor Detail

DataBuffer

public DataBuffer()
Deprecated. 
Method Detail

process

public static boolean process(DataIterator iterator,
                              DataVisitor visitor)
Deprecated. 
Processes data from specified iterator via specified visitor. Returns true if some data may still remain in the iterator or false if all data were processed.


size

public int size()
Deprecated. 
Returns number of records in this data buffer.


isEmpty

public boolean isEmpty()
Deprecated. 
Returns true if this data buffer has no records.


clear

public void clear()
Deprecated. 
Clears this data buffer.


getCipher

public int getCipher(int index)
Deprecated. 
Returns cipher of the record by its index within this buffer. Returns 0 if not encoded.

Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

getSymbol

public java.lang.String getSymbol(int index)
Deprecated. 
Returns symbol of the record by its index within this buffer. Returns null if encoded.

Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

getRecord

public DataRecord getRecord(int index)
Deprecated. 
Returns record by its index within this buffer.

Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

getTime

public long getTime(int index)
Deprecated. 
Returns time of the record given by its index within this buffer. Time of the record is composed 0th and 1st ints in the record.

Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).
java.lang.IllegalArgumentException - is the corresponding record has no time.

getInt

public int getInt(int index,
                  int int_field_index)
Deprecated. 
Returns specified Int-field of the record by its index within this buffer.

Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).
java.lang.IndexOutOfBoundsException - if the int_field_index is out of range (int_field_index < 0 || int_field_index >= getIntFieldCount()) of corresponding record.

getObj

public java.lang.Object getObj(int index,
                               int obj_field_index)
Deprecated. 
Returns specified Obj-field of the record by its index within this buffer.

Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).
java.lang.IndexOutOfBoundsException - if the obj_field_index is out of range (obj_field_index < 0 || obj_field_index >= getObjFieldCount()) of corresponding record.

replaceFields

public void replaceFields(int index,
                          DataBuffer src_buffer,
                          int src_index)
Deprecated. Used by History implementation - to be reconcidered.

Replaces field values for specified record. :TODO: reconsider its usage.


replaceFields

public void replaceFields(int index,
                          RecordCursor cursor)
Deprecated. Used by History implementation - to be reconcidered.

Replaces field values for specified record. :TODO: reconsider its usage.


examineRecord

public void examineRecord(int index,
                          DataVisitor visitor)
Deprecated. 
Examines record by its index within this buffer via specivied visitor.

NOTE: unlike bulk transfer methods, this method does not check DataVisitor.hasCapacity() method of specified visitor.

Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).

examineData

public boolean examineData(DataVisitor visitor)
Deprecated. 
Examines accumulated data via specified data visitor. Unlike retrieval, examination does not consume processed data. Returns true if not all accumulated data were examined or false if all accumulated data were examined.


examiningProvider

public DataProvider examiningProvider()
Deprecated. 

examiningIterator

public DataIterator examiningIterator()
Deprecated. 
Returns data iterator that examines this data buffer.

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.


examiningIterator

public DataIterator examiningIterator(boolean reversed)
Deprecated. 
Returns data iterator that examines this data buffer with optional reversal.

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.

Parameters:
reversed - Record order is reversed if it is true.

examiningIterator

public DataIterator examiningIterator(int index,
                                      int last_index)
Deprecated. 
Returns data iterator that examines this data buffer in the given range.

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.

Parameters:
index - first index inclusive.
last_index - exclusive.

processData

public void processData(DataIterator iterator)
Deprecated. 
Description copied from interface: DataConsumer
Processes data from specified data iterator. It is recommended that 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.

Specified by:
processData in interface DataConsumer

retrieveData

public boolean retrieveData(DataVisitor visitor)
Deprecated. 
Description copied from interface: DataProvider
Retrieves accumulated data into specified data visitor. Returns true if some data still remains in the provider or false if all accumulated data were retrieved.

Specified by:
retrieveData in interface DataProvider

setDataListener

public void setDataListener(DataListener listener)
Deprecated. 
Description copied from interface: DataProvider
Sets new data listener to receive notifications about data. Only one listener at a time is supported; the former listener is discarded. Use null to set empty data listener (no notifications).

NOTE: if there is accumulated data available, then specified listener will be notified by this method.

Specified by:
setDataListener in interface DataProvider

getCipher

public int getCipher()
Deprecated. 
Description copied from interface: DataIterator
Returns cipher for the current record returned by last call to DataIterator.nextRecord(). Returns 0 if not encoded or if no current record is being iterated.

Specified by:
getCipher in interface DataIterator

getSymbol

public java.lang.String getSymbol()
Deprecated. 
Description copied from interface: DataIterator
Returns symbol for the current record returned by last call to DataIterator.nextRecord(). Returns null if encoded or if no current record is being iterated.

Specified by:
getSymbol in interface DataIterator

nextRecord

public DataRecord nextRecord()
Deprecated. 
Description copied from interface: DataIterator
Returns next record. Returns null if no more records available.

Specified by:
nextRecord in interface DataIterator

nextIntField

public int nextIntField()
Deprecated. 
Description copied from interface: DataIterator
Returns next Int-field within current record being iterated.

Specified by:
nextIntField in interface DataIterator

nextObjField

public java.lang.Object nextObjField()
Deprecated. 
Description copied from interface: DataIterator
Returns next Obj-field within current record being iterated.

Specified by:
nextObjField in interface DataIterator

hasCapacity

public boolean hasCapacity()
Deprecated. 
Description copied from interface: DataVisitor
Returns whether visitor has capacity to efficiently visit next record. This method may be used to advise data provider that it is desirable to stop current string of visiting and to keep remaining data. However, at present, data provider is not obliged to adhere to this method contract.

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.

Specified by:
hasCapacity in interface DataVisitor

visitRecord

public void visitRecord(DataRecord record,
                        int cipher,
                        java.lang.String symbol)
Deprecated. 
Description copied from interface: DataVisitor
Visits next record.

Specified by:
visitRecord in interface DataVisitor

visitIntField

public void visitIntField(DataIntField field,
                          int value)
Deprecated. 
Description copied from interface: DataVisitor
Visits next Int-field within current record.

Specified by:
visitIntField in interface DataVisitor

visitObjField

public void visitObjField(DataObjField field,
                          java.lang.Object value)
Deprecated. 
Description copied from interface: DataVisitor
Visits next Obj-field within current record.

Specified by:
visitObjField in interface DataVisitor

completeIteration

protected void completeIteration()
Deprecated. 
Checks and completes ongoing iteration if it has finished current record.


completeVisit

protected void completeVisit()
Deprecated. 
Checks and completes ongoing visit if it has finished current record.


notifyListener

protected void notifyListener()
Deprecated. 
Notifies data listener used in DataProvider part of this data buffer. Does not check actual data availability.


ensureCapacity

protected void ensureCapacity(DataRecord record)
Deprecated. 
Ensures that this buffer has capacity to visit and store specified record. If required, reallocates all internal buffers, copies data and rearranges heads and tails to start with 0.


growLength

protected static int growLength(int length,
                                int size)
Deprecated. 
Grows length twice until it is larger than size.


copy

protected static void copy(java.lang.Object src,
                           java.lang.Object dst,
                           int head,
                           int tail,
                           int length)
Deprecated. 
Copies cyclic array buffer from source to destination. Uses source, source head index, source tail index and source length. The destination buffer will start with 0 and end with original size.