Class MessageParserImpl
java.lang.Object
com.sun.corba.ee.impl.protocol.MessageParserImpl
- All Implemented Interfaces:
MessageParser
An implementation of a
MessageParser that knows how to parse
bytes into a GIOP protocol data unit.-
Constructor Summary
ConstructorsConstructorDescriptionMessageParserImpl(ORB orb) Creates a new instance of MessageParserImplMessageParserImpl(ORB orb, Connection connection) -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckTimeout(long timeSinceLastInput) Checks for a stalled or rogue client.Returns the full message constructed by the last call toMessageParser.offerBuffer(ByteBuffer).Returns the byte buffer (if any) associated with the last message returned.getNewBufferAndCopyOld(ByteBuffer byteBuffer) intGet the starting position where the next message in theByteBuffergiven toparseBytes()begins.Returns a buffer containing whatever is left after processing the buffer provided inMessageParser.offerBuffer(ByteBuffer), which could be the same buffer.intReturn the suggested number of bytes needed to hold the next message to be parsed.booleanAre there more bytes to be parsed in theByteBuffergiven to this MessageParser'sparseBytes?booleanbooleanIs this MessageParser expecting more data ?voidofferBuffer(ByteBuffer buffer) Offers an input buffer to the parser.parseBytes(ByteBuffer byteBuffer, Connection connection) If there are sufficient bytes in theByteBufferto compose aMessage, then return a newly initializedMessage.voidsetNextMessageStartPosition(int position) Set the starting position where the next message in theByteBuffergiven toparseBytes()begins.toString()Return a string representing this MessageParser's state
-
Constructor Details
-
MessageParserImpl
Creates a new instance of MessageParserImpl- Parameters:
orb- the ORB
-
MessageParserImpl
-
-
Method Details
-
getNewBufferAndCopyOld
- Specified by:
getNewBufferAndCopyOldin interfaceMessageParser
-
isExpectingMoreData
public boolean isExpectingMoreData()Is this MessageParser expecting more data ?- Specified by:
isExpectingMoreDatain interfaceMessageParser- Returns:
- - True if more bytes are needed to construct at least one GIOP protocol data unit. False, if no additional bytes are remain to be parsed into a GIOP protocol data unit.
-
isExpectingFragments
public boolean isExpectingFragments()- Specified by:
isExpectingFragmentsin interfaceMessageParser
-
getMsgByteBuffer
Description copied from interface:MessageParserReturns the byte buffer (if any) associated with the last message returned.- Specified by:
getMsgByteBufferin interfaceMessageParser- Returns:
- the associated byte buffer
-
offerBuffer
Description copied from interface:MessageParserOffers an input buffer to the parser. Position must be set to 0, and the buffer must contain at least the start of a GIOP message. The parser will consume what it can and make the remainder available inMessageParser.getRemainderBuffer()- Specified by:
offerBufferin interfaceMessageParser- Parameters:
buffer- a buffer containing at least the start of a GIOP message.
-
getRemainderBuffer
Description copied from interface:MessageParserReturns a buffer containing whatever is left after processing the buffer provided inMessageParser.offerBuffer(ByteBuffer), which could be the same buffer. The buffer could also be null if all data has been consumed.- Specified by:
getRemainderBufferin interfaceMessageParser- Returns:
- a byte buffer representing data which still needs to be processed.
-
getMessageMediator
Description copied from interface:MessageParserReturns the full message constructed by the last call toMessageParser.offerBuffer(ByteBuffer). Will be null if the last such call did not complete a message.- Specified by:
getMessageMediatorin interfaceMessageParser- Returns:
- a complete message, wrapped in a message mediator.
-
checkTimeout
public void checkTimeout(long timeSinceLastInput) Description copied from interface:MessageParserChecks for a stalled or rogue client. If in the middle of receiving a message and the time exceeds the limit, will throw a communications failure exception.- Specified by:
checkTimeoutin interfaceMessageParser- Parameters:
timeSinceLastInput- the number of milliseconds since the last input was received.
-
parseBytes
Description copied from interface:MessageParserIf there are sufficient bytes in theByteBufferto compose aMessage, then return a newly initializedMessage. Otherwise, return null. When this method is first called, it is assumed thatByteBuffer.position()points to the location in theByteBufferwhere the beginning of the firstMessagebegins. If there is no partialMessageremaining in theByteBufferwhen this method exits, this method will ethis.expectingMoreDatatofalse. Otherwise, it will be set totrue. Callees of this method may checkisExpectingMoreData()subsequently to determine if thisMessageParseris expecting more data to complete a protocol data unit. Callees may also subsequently checkhasMoreBytesToParse()to determine if thisMessageParserhas more data to parse in the givenByteBuffer.- Specified by:
parseBytesin interfaceMessageParser- Parameters:
byteBuffer- Buffer to parseconnection- connection for message- Returns:
Messageif one is found in theByteBuffer. Otherwise, returns null.
-
hasMoreBytesToParse
public boolean hasMoreBytesToParse()Are there more bytes to be parsed in theByteBuffergiven to this MessageParser'sparseBytes? This method is typically called after a call toparseBytes()to determine if theByteBufferhas more bytes which need to parsed into aMessage.- Specified by:
hasMoreBytesToParsein interfaceMessageParser- Returns:
trueif there are more bytes to be parsed. Otherwisefalse.
-
setNextMessageStartPosition
public void setNextMessageStartPosition(int position) Set the starting position where the next message in theByteBuffergiven toparseBytes()begins.- Specified by:
setNextMessageStartPositionin interfaceMessageParser- Parameters:
position- the next starting position
-
getNextMessageStartPosition
public int getNextMessageStartPosition()Get the starting position where the next message in theByteBuffergiven toparseBytes()begins.- Specified by:
getNextMessageStartPositionin interfaceMessageParser- Returns:
- start position in the buffer of the next message
-
toString
-
getSizeNeeded
public int getSizeNeeded()Return the suggested number of bytes needed to hold the next message to be parsed.- Specified by:
getSizeNeededin interfaceMessageParser- Returns:
- bytes needed to hold message
-