Configuration Platform SDK 7.6 API Reference

com.genesyslab.platform.commons.protocol
Class MessageParser

java.lang.Object
  extended bycom.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.


Nested Class Summary
static interface MessageParser.ErrorHandler
           
 
Constructor Summary
MessageParser(ProtocolFactory protocolFactory)
           
 
Method Summary
 ProtocolFactory getFactory()
           
 Message parse(byte[] bytes)
          This method will try to extract IMessage object from the given byte array.
 Message parse(byte[] bytes, int pos, int len)
          This method will try to extract IMessage object from the given byte array, beginning from specified position.
 void setErrorHandler(MessageParser.ErrorHandler errorHandler)
          Message parser can detect some errors which are not critical to message parsing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageParser

public MessageParser(ProtocolFactory protocolFactory)
Method Detail

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 message
pos - position where message (number of attributes byte) begins
len - 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

Configuration Platform SDK 7.6 API Reference

Send comments on this topic.
Copyright © 2006–2008 Genesys Telecommunication Laboratories, Inc. All rights reserved.