Class MessageFactory

java.lang.Object
marauroa.common.net.MessageFactory

public class MessageFactory extends Object
MessageFactory is the class that is in charge of building the messages from the stream of bytes. MessageFactory follows the singleton pattern.
  • Method Details

    • getFactory

      public static MessageFactory getFactory()
      This method returns an instance of MessageFactory
      Returns:
      A shared instance of MessageFactory
    • getMessage

      public Message getMessage(byte[] data) throws IOException, InvalidVersionException
      Returns a object of the right class from a stream of serialized data.
      Parameters:
      data - the serialized data
      Returns:
      a message of the right class
      Throws:
      IOException - in case of problems with the message
      InvalidVersionException - if the message version doesn't match
    • getMessage

      public Message getMessage(byte[] data, int offset) throws IOException, InvalidVersionException
      Returns a object of the right class from a stream of serialized data.
      Parameters:
      data - the serialized data
      offset - where to start reading in the data-array.
      Returns:
      a message of the right class
      Throws:
      IOException - in case of problems with the message
      InvalidVersionException - if the message version doesn't match
    • getMessage

      public Message getMessage(Map<String,​Object> in) throws IOException
      Returns a object of the right class from a stream of serialized data.
      Parameters:
      in - the serialized data
      Returns:
      a message of the right class
      Throws:
      IOException - in case of problems with the message