com.genesyslab.platform.commons.protocol
Class MessageParser
java.lang.Object
com.genesyslab.platform.commons.protocol.MessageParser
- public class MessageParser
- extends java.lang.Object
This class can be used for manual extracting Message object from byte array.
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MessageParser
public MessageParser(ProtocolFactory protocolFactory)
getFactory
public ProtocolFactory getFactory()
parse
public Message parse(byte[] bytes,
int pos,
int len)
throws ProtocolException
- This method will try to extract IMessage object from the given byte array,
beginning from specified position. In some cases the length of the packed message (4 bytes)
can be included in byte array. Note that all parse methods do not expect length or
any other data in the buffer. Modify starting position and length accordingly to cut those
length or additional data off.
- Parameters:
bytes
- binary aray containing representation of messagepos
- position where message (number of attributes byte) beginslen
- length of binary representaion
- Returns:
- Parsed message
- Throws:
ProtocolException
- if message can't be parsed
parse
public Message parse(byte[] bytes)
throws ProtocolException
- This method will try to extract IMessage object from the given byte array.
In some cases the length of the packed message (4 bytes)
can be included in byte array. Note that all parse methods do not expect length or
any other data in the buffer.
- Parameters:
bytes
- binary aray containing representation of message
- Returns:
- Parsed message
- Throws:
ProtocolException
- if message can't be parsed
setErrorHandler
public void setErrorHandler(MessageParser.ErrorHandler errorHandler)
- Message parser can detect some errors which are not critical to message parsing.
One such example is unknown message attributes. Such errors can be reported to
ErrorHandler.
- Parameters:
errorHandler
- erro handler to report non-critical errors
Send comments on this topic.
Copyright © 2006–2008 Genesys Telecommunication Laboratories, Inc. All rights reserved.