com.devexperts.qd.qtp
Class ByteArrayComposer
java.lang.Object
com.devexperts.qd.qtp.AbstractMessageVisitor
com.devexperts.qd.qtp.AbstractByteArrayComposer
com.devexperts.qd.qtp.ByteArrayComposer
- All Implemented Interfaces:
- DataVisitor, RecordSink, MessageVisitor, SubscriptionVisitor
public class ByteArrayComposer
- extends AbstractByteArrayComposer
- implements RecordSink
The ByteArrayComposer
composes QTP messages and accumulates them
in a linear byte array buffer.
- See Also:
AbstractByteArrayComposer
Constructor Summary |
ByteArrayComposer(DataScheme scheme)
Constructs composer with a specified scheme in a stateless mode
(describe messages are not being composed). |
ByteArrayComposer(DataScheme scheme,
boolean describeRecords)
Constructs composer with a specified scheme and a describe records mode. |
Methods inherited from class com.devexperts.qd.qtp.AbstractByteArrayComposer |
beginMessage, endMessage, getBuffer, getProcessed, getThreshold, hasCapacity, moveDataForward, removeBytes, setThreshold, visitData, visitIntField, visitObjField, visitOtherMessage, visitRecord, visitRecord, visitSubscription |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ByteArrayComposer
public ByteArrayComposer(DataScheme scheme)
- Constructs composer with a specified scheme in a stateless mode
(describe messages are not being composed).
It is the same as
ByteArrayComposer(scheme, false)
.
- Parameters:
scheme
- Data scheme to use.
ByteArrayComposer
public ByteArrayComposer(DataScheme scheme,
boolean describeRecords)
- Constructs composer with a specified scheme and a describe records mode.
- Parameters:
scheme
- Data scheme to use.describeRecords
- If true
, then describe messages are composed right before
records are used for the first time and this instance keeps its state and shall not be
reused for different communication sessions.
resetSession
public void resetSession()
- Description copied from class:
AbstractByteArrayComposer
- Resets session state for composer with describe records mode. Resets the state of all described
records so far, so that describe messages are started to being sent again, as if this composer
was just created.
- Overrides:
resetSession
in class AbstractByteArrayComposer
- See Also:
AbstractByteArrayComposer.AbstractByteArrayComposer(DataScheme, boolean)
makeHeartbeat
public void makeHeartbeat()
- Writes a special heartbeat mark to the data output.
It is used in transmitting data when no significant data is being sent
to make sure that the connection is still alive.
append
public void append(RecordCursor cursor)
- Specified by:
append
in interface RecordSink
visitDescribeProtocol
public void visitDescribeProtocol(ProtocolDescriptor descriptor)
- Specified by:
visitDescribeProtocol
in interface MessageVisitor
- Overrides:
visitDescribeProtocol
in class AbstractMessageVisitor
composeRecord
protected void composeRecord(DataRecord record,
int cipher,
java.lang.String symbol)
throws java.io.IOException
- Specified by:
composeRecord
in class AbstractByteArrayComposer
- Throws:
java.io.IOException
composeHistorySubscriptionTime
protected void composeHistorySubscriptionTime(DataRecord record,
long time)
throws java.io.IOException
- Specified by:
composeHistorySubscriptionTime
in class AbstractByteArrayComposer
- Throws:
java.io.IOException
composeIntField
protected void composeIntField(DataIntField field,
int value)
throws java.io.IOException
- Specified by:
composeIntField
in class AbstractByteArrayComposer
- Throws:
java.io.IOException
composeObjField
protected void composeObjField(DataObjField field,
java.lang.Object value)
throws java.io.IOException
- Specified by:
composeObjField
in class AbstractByteArrayComposer
- Throws:
java.io.IOException
composeOtherMessageBody
protected void composeOtherMessageBody(byte[] messageBytes,
int offset,
int length)
throws java.io.IOException
- Specified by:
composeOtherMessageBody
in class AbstractByteArrayComposer
- Throws:
java.io.IOException
composeMessageHeader
protected void composeMessageHeader(int messageTypeId)
throws java.io.IOException
- Description copied from class:
AbstractByteArrayComposer
- Composes header of a message of specific type.
- Specified by:
composeMessageHeader
in class AbstractByteArrayComposer
- Parameters:
messageTypeId
- id of message type (see MessageConstants
).
- Throws:
java.io.IOException
- never. If it has been thrown then it means an internal error.
finishComposingMessage
protected void finishComposingMessage(int messageStart)
throws java.io.IOException
- Description copied from class:
AbstractByteArrayComposer
- Performs actions necessary to finish composing a message
(for example, inserts message size, inserts records descriptions if necessary).
Used by
ByteArrayComposer
.
- Specified by:
finishComposingMessage
in class AbstractByteArrayComposer
- Parameters:
messageStart
- position in buffer where message begins. The end of a message
is at current buffer position (out.getPosition()
).
- Throws:
java.io.IOException
- never.