com.devexperts.qd.kit
Class DefaultRecord

java.lang.Object
  extended by com.devexperts.qd.kit.DefaultRecord
All Implemented Interfaces:
DataRecord, RecordReader

public class DefaultRecord
extends java.lang.Object
implements DataRecord

The DefaultRecord is a basic implementation of data record.


Field Summary
protected  boolean has_time
           
protected  int id
           
protected  DataIntField[] int_fields
           
protected  java.lang.String name
           
protected  DataObjField[] obj_fields
           
protected  DataScheme scheme
           
 
Constructor Summary
DefaultRecord(int id, java.lang.String name, boolean has_time, DataIntField[] int_fields, DataObjField[] obj_fields)
           
 
Method Summary
 int getId()
          Returns identifier of this record.
 DataIntField getIntField(int index)
          Returns Int-field by its index within this record.
 int getIntFieldCount()
          Returns a number of Int-fields in this record.
 java.lang.String getName()
          Returns name of this record.
 DataObjField getObjField(int index)
          Returns Obj-field by its index within this record.
 int getObjFieldCount()
          Returns a number of Obj-fields in this record.
 DataRecord getResultingRecord()
          Returns actual DataRecord that shall be used for subscription.
 DataScheme getScheme()
          Returns parent DataScheme of this field.
 boolean hasTime()
          Determines if this record contains time coordinate.
 void readRecord(com.devexperts.io.BufferedInput in, RecordBuffer buffer, int cipher, java.lang.String symbol)
          Reads record from the specified input and adds it to the specified cursor.
static void setParentReferences(DefaultRecord record)
           
 void setScheme(DataScheme scheme)
          Sets reference to parent data scheme.
 java.lang.String toString()
           
 boolean update(RecordCursor from, RecordCursor to)
          Updates this record's field values in to cusor by values from cursor.
 void writeFields(com.devexperts.io.BufferedOutput out, RecordCursor cursor)
          Writes this record's field values in a binary form into a specified output byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

scheme

protected DataScheme scheme

id

protected final int id

name

protected final java.lang.String name

has_time

protected final boolean has_time

int_fields

protected final DataIntField[] int_fields

obj_fields

protected final DataObjField[] obj_fields
Constructor Detail

DefaultRecord

public DefaultRecord(int id,
                     java.lang.String name,
                     boolean has_time,
                     DataIntField[] int_fields,
                     DataObjField[] obj_fields)
Method Detail

setScheme

public void setScheme(DataScheme scheme)
Sets reference to parent data scheme.

Throws:
java.lang.IllegalStateException - if parent scheme already set to different instance.

setParentReferences

public static void setParentReferences(DefaultRecord record)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getScheme

public DataScheme getScheme()
Description copied from interface: DataRecord
Returns parent DataScheme of this field.

Specified by:
getScheme in interface DataRecord

getId

public int getId()
Description copied from interface: DataRecord
Returns identifier of this record. The identifier coincides with record index in its parent DataScheme. It is also used for identification of data record in serialized form.

Specified by:
getId in interface DataRecord

getName

public java.lang.String getName()
Description copied from interface: DataRecord
Returns name of this record. The name must be unique within whole DataScheme. It is recommended that full names of record's fields contain record name as a prefix like these: "FooRecord.Category", "FooRecord.Amount", etc.

Specified by:
getName in interface DataRecord

hasTime

public boolean hasTime()
Description copied from interface: DataRecord
Determines if this record contains time coordinate.

Specified by:
hasTime in interface DataRecord

getIntFieldCount

public int getIntFieldCount()
Description copied from interface: DataRecord
Returns a number of Int-fields in this record.

Specified by:
getIntFieldCount in interface DataRecord

getIntField

public DataIntField getIntField(int index)
Description copied from interface: DataRecord
Returns Int-field by its index within this record.

Specified by:
getIntField in interface DataRecord

getObjFieldCount

public int getObjFieldCount()
Description copied from interface: DataRecord
Returns a number of Obj-fields in this record.

Specified by:
getObjFieldCount in interface DataRecord

getObjField

public DataObjField getObjField(int index)
Description copied from interface: DataRecord
Returns Obj-field by its index within this record.

Specified by:
getObjField in interface DataRecord

update

public boolean update(RecordCursor from,
                      RecordCursor to)
Description copied from interface: DataRecord
Updates this record's field values in to cusor by values from cursor. This method is used for implementation of ticker contract.

Specified by:
update in interface DataRecord
Returns:
true if any values were updated and listeners shall be notified on data change.

writeFields

public void writeFields(com.devexperts.io.BufferedOutput out,
                        RecordCursor cursor)
                 throws java.io.IOException
Description copied from interface: DataRecord
Writes this record's field values in a binary form into a specified output byte array. The bytes written should be the same as if each field is individually written using DataIntField.writeInt(java.io.DataOutput, int) and DataObjField.writeObj(java.io.DataOutput, Object).

EXPERIMENTAL: This method is not actually used yet.

Specified by:
writeFields in interface DataRecord
Throws:
java.io.IOException

readRecord

public final void readRecord(com.devexperts.io.BufferedInput in,
                             RecordBuffer buffer,
                             int cipher,
                             java.lang.String symbol)
                      throws java.io.IOException
Description copied from interface: RecordReader
Reads record from the specified input and adds it to the specified cursor. DataRecord implementation of this method reads the record itself, but other implementations might perform complex transformations or do not read anything at all.

Specified by:
readRecord in interface RecordReader
Throws:
java.io.IOException

getResultingRecord

public final DataRecord getResultingRecord()
Description copied from interface: RecordReader
Returns actual DataRecord that shall be used for subscription. It might return null if this reader does not actually read anything. DataRecord implementation of this method returns this.

Specified by:
getResultingRecord in interface RecordReader