public class MessageParserImpl extends Object implements MessageParser
MessageParser that knows how to parse
bytes into a GIOP protocol data unit.| Constructor and Description |
|---|
MessageParserImpl(ORB orb)
Creates a new instance of MessageParserImpl
|
MessageParserImpl(ORB orb,
Connection connection) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkTimeout(long timeSinceLastInput)
Checks for a stalled or rogue client.
|
MessageMediator |
getMessageMediator()
Returns the full message constructed by the last call to
MessageParser.offerBuffer(ByteBuffer). |
ByteBuffer |
getMsgByteBuffer()
Returns the byte buffer (if any) associated with the last message returned.
|
ByteBuffer |
getNewBufferAndCopyOld(ByteBuffer byteBuffer) |
int |
getNextMessageStartPosition()
Get the starting position where the next message in the
ByteBuffer given to parseBytes() begins. |
ByteBuffer |
getRemainderBuffer()
Returns a buffer containing whatever is left after processing the buffer provided in
MessageParser.offerBuffer(ByteBuffer),
which could be the same buffer. |
int |
getSizeNeeded()
Return the suggested number of bytes needed to hold the next message
to be parsed.
|
boolean |
hasMoreBytesToParse()
Are there more bytes to be parsed in the
ByteBuffer given
to this MessageParser's parseBytes ?
This method is typically called after a call to parseBytes()
to determine if the ByteBuffer has more bytes which need to
parsed into a Message. |
boolean |
isExpectingFragments() |
boolean |
isExpectingMoreData()
Is this MessageParser expecting more data ?
|
void |
offerBuffer(ByteBuffer buffer)
Offers an input buffer to the parser.
|
Message |
parseBytes(ByteBuffer byteBuffer,
Connection connection)
If there are sufficient bytes in the
ByteBuffer to compose a
Message, then return a newly initialized Message. |
void |
setNextMessageStartPosition(int position)
Set the starting position where the next message in the
ByteBuffer given to parseBytes() begins. |
String |
toString()
Return a string representing this MessageParser's state
|
public MessageParserImpl(ORB orb)
public MessageParserImpl(ORB orb, Connection connection)
public ByteBuffer getNewBufferAndCopyOld(ByteBuffer byteBuffer)
getNewBufferAndCopyOld in interface MessageParserpublic boolean isExpectingMoreData()
isExpectingMoreData in interface MessageParserpublic boolean isExpectingFragments()
isExpectingFragments in interface MessageParserpublic ByteBuffer getMsgByteBuffer()
MessageParsergetMsgByteBuffer in interface MessageParserpublic void offerBuffer(ByteBuffer buffer)
MessageParserMessageParser.getRemainderBuffer()offerBuffer in interface MessageParserbuffer - a buffer containing at least the start of a GIOP message.public ByteBuffer getRemainderBuffer()
MessageParserMessageParser.offerBuffer(ByteBuffer),
which could be the same buffer. The buffer could also be null if all data has been consumed.getRemainderBuffer in interface MessageParserpublic MessageMediator getMessageMediator()
MessageParserMessageParser.offerBuffer(ByteBuffer). Will be null if
the last such call did not complete a message.getMessageMediator in interface MessageParserpublic void checkTimeout(long timeSinceLastInput)
MessageParsercheckTimeout in interface MessageParsertimeSinceLastInput - the number of milliseconds since the last input was received.public Message parseBytes(ByteBuffer byteBuffer, Connection connection)
MessageParserByteBuffer to compose a
Message, then return a newly initialized Message.
Otherwise, return null.
When this method is first called, it is assumed that
ByteBuffer.position() points to the location in the
ByteBuffer where the beginning of the first
Message begins.
If there is no partial Message remaining in the
ByteBuffer when this method exits, this method will e
this.expectingMoreData to false.
Otherwise, it will be set to true.
Callees of this method may check isExpectingMoreData()
subsequently to determine if this MessageParser is expecting
more data to complete a protocol data unit. Callees may also
subsequently check hasMoreBytesToParse() to determine if this
MessageParser has more data to parse in the given
ByteBuffer.parseBytes in interface MessageParserMessage if one is found in the ByteBuffer.
Otherwise, returns null.public boolean hasMoreBytesToParse()
ByteBuffer given
to this MessageParser's parseBytes ?
This method is typically called after a call to parseBytes()
to determine if the ByteBuffer has more bytes which need to
parsed into a Message.hasMoreBytesToParse in interface MessageParsertrue if there are more bytes to be parsed.
Otherwise false.public void setNextMessageStartPosition(int position)
ByteBuffer given to parseBytes() begins.setNextMessageStartPosition in interface MessageParserpublic int getNextMessageStartPosition()
ByteBuffer given to parseBytes() begins.getNextMessageStartPosition in interface MessageParserpublic String toString()
public int getSizeNeeded()
getSizeNeeded in interface MessageParserCopyright © 2017–2019 Eclipse Foundation. All rights reserved.