Interface MessageFormatter


public interface MessageFormatter
MessageFormatter is used to populate/format a message. It supports writing once only to each field. Attempting to set an already set element will fail.

Note that the behavior is undefined if

  • Method Details

    • setElement

      void setElement(Name name, boolean value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.
      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null.
    • setElement

      void setElement(Name name, char value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.
      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null.
    • setElement

      void setElement(Name name, int value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.
      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null.
    • setElement

      void setElement(Name name, long value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.
      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null.
    • setElement

      void setElement(Name name, float value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.
      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null.
    • setElement

      void setElement(Name name, double value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.
      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null.
    • setElement

      void setElement(Name name, Datetime value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.
      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null or value is null.
    • setElement

      void setElement(Name name, String value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message, or if the element identified by name has already been set, an exception is thrown.

      The behavior is undefined unless value is not null.

      Clients wishing to format null values (e.g. for the purpose of cache management) should not use this function; use setElementNull(com.bloomberglp.blpapi.Name) instead.

      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null or value is null.
    • setElement

      void setElement(Name name, byte[] value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.

      The behavior is undefined unless value is not null.

      Clients wishing to format null values (e.g. for the purpose of cache management) should not use this function; use setElementNull(com.bloomberglp.blpapi.Name) instead.

      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null or value is null.
    • setElement

      void setElement(Name name, Name value)
      Sets the element with the specified name to the specified value in the current message referenced by this MessageFormatter. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.
      Parameters:
      name - name of the element.
      value - the value to be set.
      Throws:
      IllegalArgumentException - if name is null or value is null.
    • setElementNull

      void setElementNull(Name name)
      Creates a null element with the specified name. Note that whether or not fields containing null values are published to subscribers is dependent upon details of the service and the schema configuration. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.
      Parameters:
      name - name of the element.
      Throws:
      IllegalArgumentException - if name is null.
    • pushElement

      void pushElement(Name name)
      Changes the level at which this MessageFormatter is operating to the specified element name. The element name must identify either a choice, a sequence or an array at the current level of the schema or the behavior is undefined. If the name is invalid for the current message or if the element identified by name has already been set, an exception is thrown.

      After this returns, the context of the MessageFormatter is set to the element name in the schema and any calls to setElement(com.bloomberglp.blpapi.Name, boolean) or pushElement(com.bloomberglp.blpapi.Name) are applied at that level.

      If name represents an array of scalars then appendValue(boolean) must be used to add values.

      If name represents an array of complex types then appendElement() creates the first entry and sets the context of the MessageFormatter to that element. Calling appendElement() again will create another entry.

      Parameters:
      name - name of the element.
      Throws:
      IllegalArgumentException - if name is null.
    • popElement

      void popElement()
      Undoes the most recent call to pushElement(com.bloomberglp.blpapi.Name) on this MessageFormatter and returns the context of the MessageFormatter to where it was before the call to pushElement(com.bloomberglp.blpapi.Name). Once popElement() has been called it is invalid to attempt to re-visit the same context.
    • appendValue

      void appendValue(boolean value)
      Appends the specified value to the element on which this MessageFormatter is operating. Throws an exception if the schema of the message is flat or the current element to which value is appended is not an array.
      Parameters:
      value - the value to be appended to this array.
    • appendValue

      void appendValue(char value)
      Appends the specified value to the element on which this MessageFormatter is operating. Throws an exception if the schema of the message is flat or the current element to which value is appended is not an array.
      Parameters:
      value - the value to be appended to this array.
    • appendValue

      void appendValue(int value)
      Appends the specified value to the element on which this MessageFormatter is operating. Throws an exception if the schema of the message is flat or the current element to which value is appended is not an array.
      Parameters:
      value - the value to be appended to this array.
    • appendValue

      void appendValue(long value)
      Appends the specified value to the element on which this MessageFormatter is operating. Throws an exception if the schema of the message is flat or the current element to which value is appended is not an array.
      Parameters:
      value - the value to be appended to this array.
    • appendValue

      void appendValue(float value)
      Appends the specified value to the element on which this MessageFormatter is operating. Throws an exception if the schema of the message is flat or the current element to which value is appended is not an array.
      Parameters:
      value - the value to be appended to this array.
    • appendValue

      void appendValue(double value)
      Appends the specified value to the element on which this MessageFormatter is operating. Throws an exception if the schema of the message is flat or the current element to which value is appended is not an array.
      Parameters:
      value - the value to be appended to this array.
    • appendValue

      void appendValue(Datetime value)
      Appends the specified value to the element on which this MessageFormatter is operating. Throws an exception if the schema of the message is flat or the current element to which value is appended is not an array.
      Parameters:
      value - the value to be appended to this array.
      Throws:
      IllegalArgumentException - if value is null.
    • appendValue

      void appendValue(String value)
      Appends the specified value to the element on which this MessageFormatter is operating. Throws an exception if the schema of the message is flat or the current element to which value is appended is not an array.
      Parameters:
      value - the value to be appended to this array.
      Throws:
      IllegalArgumentException - if value is null.
    • appendValue

      void appendValue(Name value)
      Appends the specified value to the element on which this MessageFormatter is operating. Throws an exception if the schema of the message is flat or the current element to which value is appended is not an array.
      Parameters:
      value - the value to be appended to this array.
      Throws:
      IllegalArgumentException - if value is null.
    • appendElement

      void appendElement()
      Creates an array element and appends it to the element on which this MessageFormatter is operating on. Throws an exception if the schema of the message is flat.
    • formatMessageXml

      void formatMessageXml(String message)
      Formats the message from its XML representation. An exception is thrown if the method fails to format the message. The behavior is undefined if further formatting is done using this MessageFormatter.
      Parameters:
      message - XML representation of the message.
      Throws:
      IllegalArgumentException - if message is null.