Class WfMessageCreator

java.lang.Object
org.whiteflagprotocol.java.core.WfMessageCreator

public final class WfMessageCreator extends Object
Whiteflag message creator class

This is a builder class to create a basic Whiteflag message. It contains the logic based on the Whiteflag specification to create a valid Whiteflag message object.

Since:
1.0
Whiteflag version:
v1-draft.6
Whiteflag standard x-reference:
4. Message Format
  • Constructor Details

    • WfMessageCreator

      public WfMessageCreator()
      Constructs a Whiteflag message creator
  • Method Details

    • create

      public final WfBasicMessage create()
      Creates the Whiteflag message base
      Returns:
      a new message base
    • type

      public final WfMessageCreator type(WfMessageType messageType)
      Creates a new empty Whiteflag base message object of the specified type
      Parameters:
      messageType - the type of the new message
      Returns:
      this message creator
    • map

      public final WfMessageCreator map(Map<String,String> headerValues, Map<String,String> bodyValues) throws WfCoreException
      Creates a new Whiteflag base message object from header and body maps
      Parameters:
      headerValues - a fieldname-to-value mapping of the message header fields
      bodyValues - a fieldname-to-value mapping of the message body fields
      Returns:
      this message creator
      Throws:
      WfCoreException - if the fieldname-to-value mapping is incorrect
    • deserialize

      public final WfMessageCreator deserialize(String serializedMsg) throws WfCoreException
      Deserializes a serialized Whiteflag message and creates a new Whiteflag base message object
      Parameters:
      serializedMsg - the uncompressed serialized message
      Returns:
      this message creator
      Throws:
      WfCoreException - if the provided values are invalid
      Since:
      1.1
    • decode

      public final WfMessageCreator decode(WfBinaryBuffer msgBuffer) throws WfCoreException
      Decodes an encoded Whiteflag message and creates a new Whiteflag base message object
      Parameters:
      msgBuffer - a buffer with the compressed binary encoded message
      Returns:
      this message creator
      Throws:
      WfCoreException - if the encoded message is invalid
      Since:
      1.1
    • getUnencryptedHeader

      public final WfMessageSegment getUnencryptedHeader(WfBinaryBuffer msgBuffer) throws WfCoreException
      Decodes an encoded Whiteflag message and creates a new Whiteflag base message object
      Parameters:
      msgBuffer - a buffer with the compressed binary encoded message
      Returns:
      the unencrypted message header
      Throws:
      WfCoreException - if the encoded message is invalid
      Since:
      1.1
    • compile

      public final WfMessageCreator compile(String[] fieldValues) throws WfCoreException
      Compiles a new Whiteflag base message object from field values
      Parameters:
      fieldValues - String array with the values for the message fields
      Returns:
      this message creator
      Throws:
      WfCoreException - if the provided values are invalid