public final class RecordCursor extends Object
int[]
and Object[]
data arrays that might constitute a part of a larger data structure.
Data can be read directly with getInt
and getObj
methods
and written with setInt
, setObj
, and other helper methods (unless cursor is
read-only
).
Users of the cursor cannot change the record and symbol this cursor works with.
To update this information (and change the read-only flag) one must own the reference to Owner
object
for this Cursor
and use Owner.setRecord
,
Owner.setSymbol
, and Owner.setReadOnly
methods.
RecordCursor
and the corresponding Owner
objects can be allocated with the following methods:
allocateOwner()
- to allocate fresh cursor without any memory allocated for record.
allocateOwner(DataRecord)
- to allocate fresh cursor with memory storage for a given record.
allocateOwner(DataRecord, int, String)
- same as above, also specify symbol.
allocateOwner(RecordCursor)
- same as above, but copies everything (including int and obj fields) from the other record source.
All freshly allocated cursors are not read-only.
Use Owner.useReadOnly
if you need them be read-only.
When you do not need Owner
, then you can save on allocation of the corresponding Owner
object
by calling the following methods:
allocate(DataRecord, int, String)
- to allocate fresh cursor with memory storage for a given record and also specify symbol.
allocate(DataRecord, String)
- to allocate fresh cursor with memory storage for a given record and also specify symbol
(this method also encodes symbol to cipher).
allocate(RecordCursor)
- same as above, but copies everything (including int and obj fields) from the other record source.
This class is not synchronized and is not thread-safe without external synchronization.
Modifier and Type | Class and Description |
---|---|
class |
RecordCursor.Owner
RecordCursor contains an implicit reference to RecordCursor . |
Constructor and Description |
---|
RecordCursor()
Deprecated.
This method will not be public in the future versions.
Use one of
RecordCursor.allocate(...) or RecordCursor.allocateOwner(...) methods. |
Modifier and Type | Method and Description |
---|---|
static RecordCursor |
allocate(DataRecord record,
int cipher,
String symbol)
Allocates writable
RecordCursor that points to a freshly allocated storage for a given record's
integer and object field values and also sets symbol. |
static RecordCursor |
allocate(DataRecord record,
int cipher,
String symbol,
RecordMode mode)
Allocates writable
RecordCursor that points to a freshly allocated storage for a given record's
integer and object field values using a specified mode and also sets symbol. |
static RecordCursor |
allocate(DataRecord record,
String symbol)
Allocates writable
RecordCursor that points to a freshly allocated storage for a given record's
integer and object field values and also sets symbol. |
static RecordCursor |
allocate(DataRecord record,
String symbol,
RecordMode mode)
Allocates writable
RecordCursor that points to a freshly allocated storage for a given record's
integer and object field values using a specified mode and also sets symbol. |
static RecordCursor |
allocate(RecordCursor source)
Allocates
RecordCursor that points to a freshly allocated storage with a copy of
data from a given source. |
static RecordCursor.Owner |
allocateOwner()
Returns newly allocated record cursor owner object.
|
static RecordCursor.Owner |
allocateOwner(DataRecord record)
Allocates writable
RecordCursor.Owner that points to a freshly allocated storage for a given record's
integer and object field values. |
static RecordCursor.Owner |
allocateOwner(DataRecord record,
int cipher,
String symbol)
Allocates writable
RecordCursor.Owner that points to a freshly allocated storage for a given record's
integer and object field values and also sets symbol. |
static RecordCursor.Owner |
allocateOwner(DataRecord record,
int cipher,
String symbol,
RecordMode mode)
Allocates writable
RecordCursor.Owner that points to a freshly allocated storage for a given record's
integer and object field values using a specified mode and also sets symbol. |
static RecordCursor.Owner |
allocateOwner(DataRecord record,
RecordMode mode)
Allocates writable
RecordCursor.Owner that points to a freshly allocated storage for a given record's
integer and object field values using a specified mode. |
static RecordCursor.Owner |
allocateOwner(RecordCursor source)
Allocates
RecordCursor.Owner that points to a freshly allocated storage with a copy of
data from a given source. |
void |
clearData() |
void |
clearDataButTime()
Clears all data fields but time (ints set to 0 and objs set to null).
|
void |
clearFields()
Deprecated.
Renamed to
clearData() |
void |
copyDataFrom(RecordCursor from)
Copies data from the specified
RecordCursor . |
void |
copyFrom(DataIterator iterator)
Copies data from the specified iterator into this cursor overwriting everything unconditionally.
|
void |
copyFrom(RecordCursor from)
Copies data and extra values from the specified cursor into this cursor overwriting everything unconditionally.
|
boolean |
examineData(DataVisitor visitor)
Examines this cursor into the specified data visitor,
passing record, symbol and all field values.
|
boolean |
examineSubscription(SubscriptionVisitor visitor)
Examines this cursor into the specified data visitor,
passing record, symbol and time (if this cursor
has time ). |
Object |
getAttachment()
Returns object attachment that is associated with the current record.
|
int |
getCipher()
Returns cipher or 0 if symbol is not coded.
|
String |
getDecodedSymbol()
Returns symbol that is decoded from cipher if needed.
|
int |
getEventFlags()
Returns event flags that are associated with the current record.
|
int |
getEventSequence()
Returns event sequence that is associated with the current record.
|
int |
getEventTimeSeconds()
Returns event time seconds value that is associated with the current record.
|
long |
getEventTimeSequence()
Returns event time sequence that is associated with the current record.
|
int |
getInt(int intFieldIndex)
Returns the value of the specified integer field for the record pointed to by this cursor.
|
int |
getIntCount()
Returns the number of integer data fields.
|
void |
getIntsTo(int intFieldIndex,
int[] to,
int offset,
int length) |
long |
getLong(int intFieldIndex)
Returns the value of the specified integer field for the record pointed to by this cursor.
|
RecordMode |
getMode()
Returns mode.
|
Object |
getObj(int objFieldIndex)
Returns the value of the specified object field for the record pointed to by this cursor.
|
int |
getObjCount()
Returns the number of object data fields.
|
void |
getObjsTo(int objFieldIndex,
Object[] to,
int offset,
int length) |
long |
getPosition()
Returns position of this cursor.
|
DataRecord |
getRecord()
Returns record.
|
String |
getSymbol()
Returns symbol or
null if symbol is coded in cipher . |
long |
getTime()
Returns time of this record that is a long value composed of the value of the first two integer fields.
|
int |
getTimeMark()
Returns time mark that is associated with the current record.
|
boolean |
hasAttachment()
Returns
true when this cursor keeps additional object attachment with each record. |
boolean |
hasEventFlags()
Returns
true when this cursor keeps additional event flags with each data record. |
boolean |
hasEventTimeSequence()
Returns
true when this cursor keeps additional long event time sequence with each data record. |
boolean |
hasLink()
Returns
true when this cursor keeps additional link to other record with each data record. |
boolean |
hasTime()
Returns
true if the cursor contains time value, that is when current
record has time and
current mode is either
DATA or HISTORY_SUBSCRIPTION . |
boolean |
hasTimeMark()
Returns
true when this cursor keeps additional integer time mark with each data record. |
boolean |
isDataIdenticalTo(RecordCursor other)
Returns
true when data contents of this cursor are equal (identity-wise) to the contents
of the other cursor. |
boolean |
isReadOnly()
Returns
true if this cursor is in read-only mode. |
boolean |
isUnlinked()
Returns
true when the current record was part of a chain unlinked with
RecordBuffer.unlinkFrom(position) method. |
void |
readDataFrom(com.devexperts.io.BufferedInput in)
Deprecated.
Use
BinaryQTPParser class |
void |
readFrom(DataInput in)
Deprecated.
Use
BinaryQTPParser class |
void |
reset()
Deprecated.
This method will not be public in the future versions.
Use
RecordCursor.Owner.reset() . |
void |
setAs(DataRecord record,
int cipher,
String symbol,
int[] int_flds,
int int_offset,
Object[] obj_flds,
int obj_offset,
boolean writable)
Deprecated.
This method will be removed in the future versions.
Use one of
RecordCursor.allocateOwner(...) to get owner and use Owner's
setXXX(...) methods to configure the cursor as needed. |
void |
setAttachment(Object attachment)
Changes object attachment that is associated with the current record.
|
void |
setEventFlags(int eventFlags)
Changes event flags that are associated with the current record.
|
void |
setEventSequence(int eventSequence)
Changes event sequence that is associated with the current record.
|
void |
setEventTimeSeconds(int eventTimeSeconds)
Changes event time seconds value that is associated with the current record.
|
void |
setEventTimeSequence(long eventTimeSequence)
Changes event time sequence that is associated with the current record.
|
void |
setInt(int intFieldIndex,
int value) |
void |
setLinkTo(long position)
Changes link to the previous record in list that is associated with the current record.
|
void |
setLong(int intFieldIndex,
long value) |
void |
setObj(int objFieldIndex,
Object value) |
void |
setTime(long time)
Changes time of this record that is a long value composed of the value of the first two integer fields.
|
void |
setTimeMark(int timeMark)
Changes time mark that is associated with the current record.
|
String |
toString() |
boolean |
updateDataFrom(RecordCursor from)
Updates data from the specified cursor into this cursor, checking each field with
DataIntField.equals(int,int) or DataObjField.equals(Object,Object) respectively. |
boolean |
updateFrom(RecordCursor from)
Deprecated.
Renamed to
updateDataFrom(RecordCursor) |
boolean |
updateIntsTo(int intFieldIndex,
int[] to,
int offset,
int length) |
boolean |
updateObjsTo(int objFieldIndex,
Object[] to,
int offset,
int length) |
public RecordCursor()
RecordCursor.allocate(...)
or RecordCursor.allocateOwner(...)
methods.public static RecordCursor allocate(RecordCursor source)
RecordCursor
that points to a freshly allocated storage with a copy of
data from a given source.
This method is a shortcut to
allocateOwner(source).cursor()
,
but this method does not actually allocate memory for Owner
object.public static RecordCursor allocate(DataRecord record, int cipher, String symbol)
RecordCursor
that points to a freshly allocated storage for a given record's
integer and object field values and also sets symbol. It uses a default DATA
mode.
This method is a shortcut to
allocateOwner(record, cipher, symbol).cursor()
,
but this method does not actually allocate memory for Owner
object.public static RecordCursor allocate(DataRecord record, int cipher, String symbol, RecordMode mode)
RecordCursor
that points to a freshly allocated storage for a given record's
integer and object field values using a specified mode and also sets symbol.
This method is a shortcut to
allocateOwner(record, cipher, symbol, mode).cursor()
,
but this method does not actually allocate memory for Owner
object.public static RecordCursor allocate(DataRecord record, String symbol)
RecordCursor
that points to a freshly allocated storage for a given record's
integer and object field values and also sets symbol. It uses a default DATA
mode.
This method is a shortcut to
allocate(record, record.getScheme().getCodec().encode(symbol), symbol)
.public static RecordCursor allocate(DataRecord record, String symbol, RecordMode mode)
RecordCursor
that points to a freshly allocated storage for a given record's
integer and object field values using a specified mode and also sets symbol.
This method is a shortcut to
allocate(record, record.getScheme().getCodec().encode(symbol), symbol, mode)
.public static RecordCursor.Owner allocateOwner(RecordCursor source)
RecordCursor.Owner
that points to a freshly allocated storage with a copy of
data from a given source.
This method is a shortcut to allocateOwner(source.getRecord(), source.getCipher(), source.getSymbol()). copyFrom(source).
public static RecordCursor.Owner allocateOwner(DataRecord record, int cipher, String symbol)
RecordCursor.Owner
that points to a freshly allocated storage for a given record's
integer and object field values and also sets symbol. It uses a default DATA
mode.
This method is a shortcut to
allocateOwner(record).setSymbol(cipher, symbol)
.public static RecordCursor.Owner allocateOwner(DataRecord record, int cipher, String symbol, RecordMode mode)
RecordCursor.Owner
that points to a freshly allocated storage for a given record's
integer and object field values using a specified mode and also sets symbol.
This method is a shortcut to
allocateOwner(record, mode).setSymbol(cipher, symbol)
.public static RecordCursor.Owner allocateOwner(DataRecord record)
RecordCursor.Owner
that points to a freshly allocated storage for a given record's
integer and object field values. It uses a default DATA
mode.
This method is a shortcut to Owner.allocateOwner().setRecord(record, new int[record.getIntFieldCount()], 0, new Object[record.getObjFieldCount()], 0)
public static RecordCursor.Owner allocateOwner(DataRecord record, RecordMode mode)
RecordCursor.Owner
that points to a freshly allocated storage for a given record's
integer and object field values using a specified mode.public static RecordCursor.Owner allocateOwner()
Owner.setRecord
, Owner.setSymbol
, and Owner.setReadOnly
methods to configure the corresponding cursor.public DataRecord getRecord()
public RecordMode getMode()
public int getCipher()
public String getSymbol()
null
if symbol is coded in cipher
.public String getDecodedSymbol()
public int getIntCount()
public int getInt(int intFieldIndex)
intFieldIndex
- index of the field starting from 0.IndexOutOfBoundsException
- if intFieldIndex is negative or more or equal to the number of
integer fields in the corresponding record.public long getLong(int intFieldIndex)
intFieldIndex
- index of the field starting from 0.IndexOutOfBoundsException
- if intFieldIndex is negative or more or equal to the number of
integer fields in the corresponding record.public int getObjCount()
public Object getObj(int objFieldIndex)
objFieldIndex
- index of the field starting from 0.IndexOutOfBoundsException
- if objFieldIndex is negative or more or equal to the number of
object fields in the corresponding record.public void getIntsTo(int intFieldIndex, int[] to, int offset, int length)
public void getObjsTo(int objFieldIndex, Object[] to, int offset, int length)
public boolean updateIntsTo(int intFieldIndex, int[] to, int offset, int length)
public boolean updateObjsTo(int objFieldIndex, Object[] to, int offset, int length)
public boolean hasTime()
true
if the cursor contains time value, that is when current
record
has time
and
current mode
is either
DATA
or HISTORY_SUBSCRIPTION
.true
if the cursor contains time value.public long getTime()
hasTime
returns false
.public void setTime(long time)
hasTime
returns false
.IllegalStateException
- if the cursor is read-only
.public boolean hasEventFlags()
true
when this cursor keeps additional event flags with each data record.
Additional event flags either provided with the data when mode
has
event flags
or by the cursor owner via
Owner.setEventFlags
method.public int getEventFlags()
hasEventFlags
returns false
.TimeMarkUtil
public void setEventFlags(int eventFlags)
mode
does not have event flags
.IllegalStateException
- if the cursor is read-only
.public boolean hasTimeMark()
true
when this cursor keeps additional integer time mark with each data record.
Additional time mark is either provided with the data when mode
has
time mark
or by the cursor owner via
Owner.setTimeMark
method.TimeMarkUtil
public int getTimeMark()
hasTimeMark
returns false
.TimeMarkUtil
public void setTimeMark(int timeMark)
mode
does not have time mark
.IllegalStateException
- if the cursor is read-only
.TimeMarkUtil
public boolean hasEventTimeSequence()
true
when this cursor keeps additional long event time sequence with each data record.
It is a shortcut to
getMode
().hasEventTimeSequence
()
.TimeSequenceUtil
public long getEventTimeSequence()
hasEventTimeSequence
returns false
.TimeSequenceUtil
public int getEventTimeSeconds()
hasEventTimeSequence
returns false
.getEventTimeSequence()
,
TimeSequenceUtil
public int getEventSequence()
hasEventTimeSequence
returns false
.getEventTimeSequence()
,
TimeSequenceUtil
public void setEventTimeSequence(long eventTimeSequence)
hasEventTimeSequence
returns false
.IllegalStateException
- if the cursor is read-only
.TimeSequenceUtil
public void setEventTimeSeconds(int eventTimeSeconds)
hasEventTimeSequence
returns false
.IllegalStateException
- if the cursor is read-only
.setEventTimeSequence(long)
,
TimeSequenceUtil
public void setEventSequence(int eventSequence)
hasEventTimeSequence
returns false
.IllegalStateException
- if the cursor is read-only
.setEventTimeSequence(long)
,
TimeSequenceUtil
public boolean hasLink()
public boolean isUnlinked()
true
when the current record was part of a chain unlinked with
RecordBuffer.unlinkFrom(position)
method.
This method returns false
when hasLink
returns false
.public void setLinkTo(long position)
hasLink
returns false
.position
- the position of the previous record.IllegalStateException
- if the cursor is read-only
.IllegalArgumentException
- if position does not refer to the previous position in record buffer.public boolean hasAttachment()
true
when this cursor keeps additional object attachment with each record.
Additional object attachment is either provided with the data when mode
has
attachment
or by the cursor owner via
Owner.setAttachment
method.public Object getAttachment()
null
when hasAttachment
returns false
.public void setAttachment(Object attachment)
mode
does not have attachment
.IllegalStateException
- if the cursor is read-only
.public boolean isReadOnly()
public void setInt(int intFieldIndex, int value)
public void setLong(int intFieldIndex, long value)
public void setObj(int objFieldIndex, Object value)
public void clearFields()
clearData()
public void clearData()
public void clearDataButTime()
public void copyFrom(DataIterator iterator)
public void copyFrom(RecordCursor from)
mode
and from
mode is copied.
All values are copied when both modes are DATA
, only time if at least one
of them is HISTORY_SUBSCRIPTION
, and nothing is copied
if at least one of them is SUBSCRIPTION
(without time).
Extra values (like time sequence
,
time mark
, and attachment
)
are copied when supported in both specified from and in this cursor's modes.
This method also copies all extra information (event flags
,
time marks
, time sequence
,
and attachment
) that can be
stored under this buffer's mode (note that links
are not copied),
including cursor-local event flags, time mark and attachment that can be set via its owner's
Owner.setEventFlags
,
Owner.setTimeMark
, and
Owner.setAttachment
methods.
Symbol and record are not updated nor checked. Thus, method can be used to copy data between different symbols of the same record and/or between different records with the same fields. It is caller's responsibility to ensure that this operation makes sense.
from
- the cursor to copy from.IllegalStateException
- if the cursor is read-only
.copyDataFrom(RecordCursor)
public void copyDataFrom(RecordCursor from)
RecordCursor
.
If the specified cursor has mode that does not have full data
(HISTORY_SUBSCRIPTION
or RecordMode.SUBSCRIPTION
),
then the missing data fields are cleared.
Extra information from the cursor (like event time marks, flags, etc) is NOT copied.
Symbol and record are not updated nor checked. Thus, method can be used to copy data between different symbols of the same record and/or between different records with the same fields. It is caller's responsibility to ensure that this operation makes sense.
from
- the cursor to copy data from.IllegalStateException
- if the cursor is read-only
.IllegalArgumentException
- if the cursor has too many int/obj fields to copy into this one.RecordBuffer.addDataAndCompactIfNeeded(RecordCursor)
public boolean updateFrom(RecordCursor from)
updateDataFrom(RecordCursor)
DataIntField.equals(int,int)
or DataObjField.equals(Object,Object)
respectively.
The minimal subset of fields based on current mode
and from
mode is updated.
All values are updated when both modes are DATA
, only time if at least one
of them is HISTORY_SUBSCRIPTION
, and nothing is updated
if at least one of them is SUBSCRIPTION
(without time).
Symbol is not updated nor checked.
Extra information from the cursor (like event time marks, flags, etc) is NOT updated.
true
if anything was changed.IllegalStateException
- if the cursor is read-only
.IllegalArgumentException
- when from cursor has different record.public boolean updateDataFrom(RecordCursor from)
DataIntField.equals(int,int)
or DataObjField.equals(Object,Object)
respectively.
The minimal subset of fields based on current mode
and from
mode is updated.
All values are updated when both modes are DATA
, only time if at least one
of them is HISTORY_SUBSCRIPTION
, and nothing is updated
if at least one of them is SUBSCRIPTION
(without time).
Symbol is not updated nor checked.
Extra information from the cursor (like event time marks, flags, etc) is NOT updated.
true
if anything was changed.IllegalStateException
- if the cursor is read-only
.IllegalArgumentException
- when from cursor has different record.public boolean isDataIdenticalTo(RecordCursor other)
true
when data contents of this cursor are equal (identity-wise) to the contents
of the other cursor.
The minimal subset of fields based on current mode
and from
mode is checked.
All values are checked when both modes are DATA
, only time if at least one
of them is HISTORY_SUBSCRIPTION
, and nothing is checked
(always returns true
)
if at least one of them is SUBSCRIPTION
(without time).
Symbol is not checked.
Extra information from the cursor (like event time marks, flags, etc) is NOT checked.
IllegalStateException
- if the cursor is read-only
.IllegalArgumentException
- when other cursor has different record.public void readFrom(DataInput in) throws IOException
BinaryQTPParser
classIllegalStateException
- if the cursor is read-only
.IOException
public void readDataFrom(com.devexperts.io.BufferedInput in) throws IOException
BinaryQTPParser
classIllegalStateException
- if the cursor is read-only
.IOException
public boolean examineData(DataVisitor visitor)
RecordSink
interface this method invokes
append(this)
.visitor
- data visitor.true
when data could not be examined completely because visitor does not have capacity
(need to examine again), or false
otherwise (everything was examined).IllegalStateException
- if this cursor mode does not have data
.public boolean examineSubscription(SubscriptionVisitor visitor)
has time
).
Note, that when visitor implements RecordSink
interface this method invokes
append(this)
.visitor
- data visitor.true
when data could not be examined completely because visitor does not have capacity
(need to examine again), or false
otherwise (everything was examined).IllegalStateException
- if this cursor mode has data
.public void setAs(DataRecord record, int cipher, String symbol, int[] int_flds, int int_offset, Object[] obj_flds, int obj_offset, boolean writable)
RecordCursor.allocateOwner(...)
to get owner and use Owner's
setXXX(...)
methods to configure the cursor as needed.public void reset()
RecordCursor.Owner.reset()
.public long getPosition()
RecordBuffer
methods:
next
,
current
,
add(record,cipher,symbol)
,
add(cursor)
,
cursorAt
,
writeCursorAt
Copyright © 2002–2025 Devexperts LLC. All rights reserved.