|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.devexperts.qd.qtp.AbstractByteArrayParser
public abstract class AbstractByteArrayParser
Base class for classes that parse QTP messages data from byte array.
It consolidates common logic for text
and binary
byte array parsers.
Most of it's logic was simply extracted from ByteArrayParser.
Classes that are interested in extra-high performance can use ByteArrayParser directly, and classes that are interested in opportunity to parse data both in text and binary formats can use this class.
ByteArrayParser
,
TextByteArrayParser
,
AbstractByteArrayComposer
Field Summary | |
---|---|
protected com.devexperts.io.ByteArrayInput |
in
|
protected int |
limit
|
protected int |
processed
|
protected RecordBuffer |
recordBuffer
|
protected DataScheme |
scheme
|
protected SubscriptionBuffer |
subscriptionBuffer
|
Constructor Summary | |
---|---|
protected |
AbstractByteArrayParser(DataScheme scheme)
Constructs parser with a specified scheme. |
Method Summary | |
---|---|
void |
addBytes(byte[] bytes,
int offset,
int length)
Adds specified bytes to the end of byte array buffer. |
void |
ensureCapacity(int requiredCapacity)
Ensures that byte array buffer has at least specified capacity. |
byte[] |
getBuffer()
Returns byte array buffer where data is stored. |
int |
getLimit()
Returns number of bytes in the buffer. |
int |
getProcessed()
Returns number of processed bytes ready to be removed. |
protected void |
nextMessage(MessageConsumer consumer,
MessageType messageType)
|
abstract void |
parse(MessageConsumer consumer)
Parses accumulated data and retrieve processed messages to specified MessageConsumer. |
protected void |
processMessage(MessageType type,
MessageConsumer consumer)
Processses message from the recordBuffer or subscriptionBuffer into the consumer. |
protected void |
processPending(MessageConsumer consumer)
Processes pending message from buffers (if any) and resets pendingMessageType to null . |
void |
removeBytes(int n)
Removes specified number of bytes from the start of the buffer. |
void |
setLimit(int newLimit)
Sets new value for number of bytes in the buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final DataScheme scheme
protected final RecordBuffer recordBuffer
protected final SubscriptionBuffer subscriptionBuffer
protected final com.devexperts.io.ByteArrayInput in
protected int processed
protected int limit
Constructor Detail |
---|
protected AbstractByteArrayParser(DataScheme scheme)
scheme
- data scheme to use.Method Detail |
---|
public int getProcessed()
public byte[] getBuffer()
Note: the array instance used for buffering may change if new messages are added or previous ones are removed.
public void removeBytes(int n)
n
- number of bytes to remove.
java.lang.IllegalArgumentException
- if specified number is negative
or is larger than the number of processed bytes.public void addBytes(byte[] bytes, int offset, int length)
bytes
- array to get bytes from.offset
- position of the first byte in bytes
length
- number of bytes to add.
java.lang.IndexOutOfBoundsException
- if copying would cause
access of data outside specified byte array bounds.public int getLimit()
public void setLimit(int newLimit)
newLimit
- new value for number of bytes in the buffer.
java.lang.IllegalArgumentException
- if specified limit is less than
the number of processed bytes or is larger than the buffer capacity.public void ensureCapacity(int requiredCapacity)
Note: the array instance used for buffering may change if new messages are added or previous ones are removed. This means that specified capacity is valid only until next operation.
requiredCapacity
- capacity to ensure.public abstract void parse(MessageConsumer consumer)
processed
value.
consumer
- MessageConsumer to pass parsed messages.protected void processPending(MessageConsumer consumer)
pendingMessageType
to null
.
protected void nextMessage(MessageConsumer consumer, MessageType messageType)
protected void processMessage(MessageType type, MessageConsumer consumer)
recordBuffer
or subscriptionBuffer
into the consumer.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |