com.bloomberglp.blpapi
Class Message

java.lang.Object
  extended by com.bloomberglp.blpapi.Message

public abstract class Message
extends java.lang.Object

Message objects are used to represent all outputs from the API

Message objects are used to represent all outputs from the API including subscription data, response, administrative and status messages. Message objects are obtained from a MessageIterator. A message always has a message type and may optionally contain the following

     * topicName     - valid for Subscription data messages
     * service       - The service from which this message was received from
     * correlationId - one or more correlationIds if this message was
                       delivered for a pending request or a subscription
 

A Message object is a handle to a single underlying protocol message. The Message contents are represented as an Element and some convenient shortcuts are supplied to the Element accessors.

Author:
ssomu

Nested Class Summary
static class Message.Fragment
          A message could be split into more than one fragments to reduce each message size.
 
Method Summary
abstract  Element asElement()
          Returns the contents of this Message as a read-only Element.
abstract  CorrelationID correlationID()
          Return the correlationId associated with this message.
abstract  CorrelationID correlationID(int index)
          Return the correlationId associated with this message at the specified index
abstract  CorrelationID correlationIDAt(int index)
          Deprecated. As of 3.2.1, use correlationID(int)
abstract  Message.Fragment fragmentType()
          Return the fragment type.
abstract  Element getElement(Name name)
          Return the element of this message having the specified name.
abstract  Element getElement(java.lang.String name)
          Return the element of this message having the specified name.
abstract  boolean getElementAsBool(Name name)
          Return the value of the element having specified name as a boolean value
abstract  boolean getElementAsBool(java.lang.String name)
          Return the value of the element having specified name as a boolean value
abstract  byte[] getElementAsBytes(Name name)
          Return the value of the element having specified name as a byte array
abstract  byte[] getElementAsBytes(java.lang.String name)
          Return the value of the element having specified name as a byte array
abstract  char getElementAsChar(Name name)
          Return the value of the element having specified name as a char value
abstract  char getElementAsChar(java.lang.String name)
          Return the value of the element having specified name as a char value
abstract  Datetime getElementAsDate(Name name)
          Return the value of the element having specified name as a Date value
abstract  Datetime getElementAsDate(java.lang.String name)
          Return the value of the element having specified name as a Date value
abstract  Datetime getElementAsDatetime(Name name)
          Return the value of the element having specified name as a Datetime value
abstract  Datetime getElementAsDatetime(java.lang.String name)
          Return the value of the element having specified name as a Datetime value
abstract  float getElementAsFloat32(Name name)
          Return the value of the element having specified name as a float value
abstract  float getElementAsFloat32(java.lang.String name)
          Return the value of the element having specified name as a float value
abstract  double getElementAsFloat64(Name name)
          Return the value of the element having specified name as a double value
abstract  double getElementAsFloat64(java.lang.String name)
          Return the value of the element having specified name as a double value
abstract  int getElementAsInt32(Name name)
          Return the value of the element having specified name as a int value
abstract  int getElementAsInt32(java.lang.String name)
          Return the value of the element having specified name as a int value
abstract  long getElementAsInt64(Name name)
          Return the value of the element having specified name as a long value
abstract  long getElementAsInt64(java.lang.String name)
          Return the value of the element having specified name as a long value
abstract  Name getElementAsName(Name name)
          Return the value of the element having specified name as a Constant value
abstract  Name getElementAsName(java.lang.String name)
          Return the value of the element having specified name as a Constant value
abstract  java.lang.String getElementAsString(Name name)
          Return the value of the element having specified name as a String value
abstract  java.lang.String getElementAsString(java.lang.String name)
          Return the value of the element having specified name as a String value
abstract  Datetime getElementAsTime(Name name)
          Return the value of the element having specified name as a Time value
abstract  Datetime getElementAsTime(java.lang.String name)
          Return the value of the element having specified name as a Time value
abstract  boolean hasElement(Name name)
          Return true if this message has the element having the specified name false otherwise
abstract  boolean hasElement(Name name, boolean excludeNullElements)
          Return true if this message has the element having the specified name false otherwise
abstract  boolean hasElement(java.lang.String name)
          Return true if this message has the element having the specified name false otherwise
abstract  boolean hasElement(java.lang.String name, boolean excludeNullElements)
          Return true if this message has the element having the specified name false otherwise
abstract  boolean isValid()
           
abstract  Name messageType()
          Return the Name constant representing the type of the message
abstract  int numCorrelationIds()
          Return the number of correlation ids associated with this message.
abstract  int numElements()
          Return the number of elements contained by this message
abstract  void print(java.io.OutputStream output)
          Prints the contents of this message to OutputStream.
abstract  void print(java.io.Writer writer)
          Prints the contents of this message to Writer.
abstract  Service service()
          Return the Service associated with this message.
abstract  long timeReceivedMillis()
          Return the time when the message was received by the SDK and '0' if there is no timestamp associated with this Message.
abstract  java.lang.String topicName()
          Return the topic string associated with this message.
abstract  java.lang.String toString()
          Returns the contents of this message as a String
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

topicName

public abstract java.lang.String topicName()
Return the topic string associated with this message. Return an empty string if there is no topic associated with this message


service

public abstract Service service()
Return the Service associated with this message. Return null if this method is not associated with a service


messageType

public abstract Name messageType()
Return the Name constant representing the type of the message


fragmentType

public abstract Message.Fragment fragmentType()
Return the fragment type. The return value is a value of enum Fragment to indicate whether it is a fragmented message of a big message and its positions in fragmentation if it is.


correlationID

public abstract CorrelationID correlationID()
Return the correlationId associated with this message.

This is same as calling correlationID(0). If there is more than one correlationId associated with this message return the first correlationId. If there are no correlationIds available for this message return null

Returns:
correlationId associated with this message if available null otherwise

correlationIDAt

public abstract CorrelationID correlationIDAt(int index)
Deprecated. As of 3.2.1, use correlationID(int)


correlationID

public abstract CorrelationID correlationID(int index)
Return the correlationId associated with this message at the specified index

Normally each message is associated with only one correlationId. See "allowMultipeCorrelatorsPerMsg" option in SessionOptions for more information on when multiple correlators can be returned per message

Throws:
java.lang.IndexOutOfBoundsException - if index >= numCorrelationIds()

numCorrelationIds

public abstract int numCorrelationIds()
Return the number of correlation ids associated with this message.

Note: A Message will have exactly one CorrelationId unless "allowMultipleCorrelatorsPerMsg" option was enabled for the Session this Message came from. When allowMultipleCorrelatorsPerMsg is disabled (the default) and more than one active subscription would result in the same Message the Message is delivered multiple times (without making a physical copy). Each Message is accompanied by a single CorrelationId. When "allowMultipleCorrelatorsPerMsg" is enabled and more than one active subscription would result in the same Message the Message is delivered once with a list of corresponding CorrelationId values.

See Also:
SessionOptions

timeReceivedMillis

public abstract long timeReceivedMillis()
Return the time when the message was received by the SDK and '0' if there is no timestamp associated with this Message. System.currentTimeMillis() is used to get the current time. Note that by default the subscription data messages are not timestamped (but all the other messages are). To enable recording receive time for all messages set SessionOptions.setRecordSubscriptionDataReceiveTimes(boolean).


asElement

public abstract Element asElement()
Returns the contents of this Message as a read-only Element.


numElements

public abstract int numElements()
Return the number of elements contained by this message

Same as calling asElement().Element.numElements()


isValid

public abstract boolean isValid()

hasElement

public abstract boolean hasElement(Name name)
Return true if this message has the element having the specified name false otherwise

Same as calling asElement().Element.hasElement(Name)


hasElement

public abstract boolean hasElement(Name name,
                                   boolean excludeNullElements)
Return true if this message has the element having the specified name false otherwise

Same as calling asElement().Element.hasElement(Name, boolean)


hasElement

public abstract boolean hasElement(java.lang.String name)
Return true if this message has the element having the specified name false otherwise

Same as calling asElement().Element.hasElement(String)


hasElement

public abstract boolean hasElement(java.lang.String name,
                                   boolean excludeNullElements)
Return true if this message has the element having the specified name false otherwise

Same as calling asElement().Element.hasElement(String, boolean)


getElement

public abstract Element getElement(Name name)
Return the element of this message having the specified name.

Same as calling asElement().Element.getElement(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name

getElement

public abstract Element getElement(java.lang.String name)
Return the element of this message having the specified name.

Same as calling asElement().Element.getElement(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name

getElementAsBool

public abstract boolean getElementAsBool(Name name)
Return the value of the element having specified name as a boolean value

Same as calling asElement().Element.getElementAsBool(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a boolean value

getElementAsBool

public abstract boolean getElementAsBool(java.lang.String name)
Return the value of the element having specified name as a boolean value

Same as calling asElement().Element.getElementAsBool(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a boolean value

getElementAsBytes

public abstract byte[] getElementAsBytes(Name name)
Return the value of the element having specified name as a byte array

Same as calling asElement().Element.getElementAsBytes(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a byte array

getElementAsBytes

public abstract byte[] getElementAsBytes(java.lang.String name)
Return the value of the element having specified name as a byte array

Same as calling asElement().Element.getElementAsBytes(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a byte array

getElementAsChar

public abstract char getElementAsChar(Name name)
Return the value of the element having specified name as a char value

Same as calling asElement().Element.getElementAsChar(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a char value

getElementAsChar

public abstract char getElementAsChar(java.lang.String name)
Return the value of the element having specified name as a char value

Same as calling asElement().Element.getElementAsChar(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a char value

getElementAsInt32

public abstract int getElementAsInt32(Name name)
Return the value of the element having specified name as a int value

Same as calling asElement().Element.getElementAsInt32(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a int value

getElementAsInt32

public abstract int getElementAsInt32(java.lang.String name)
Return the value of the element having specified name as a int value

Same as calling asElement().Element.getElementAsInt32(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a int value

getElementAsInt64

public abstract long getElementAsInt64(Name name)
Return the value of the element having specified name as a long value

Same as calling asElement().Element.getElementAsInt64(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a long value

getElementAsInt64

public abstract long getElementAsInt64(java.lang.String name)
Return the value of the element having specified name as a long value

Same as calling asElement().Element.getElementAsInt64(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a long value

getElementAsFloat64

public abstract double getElementAsFloat64(Name name)
Return the value of the element having specified name as a double value

Same as calling asElement().Element.getElementAsFloat64(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a double value

getElementAsFloat64

public abstract double getElementAsFloat64(java.lang.String name)
Return the value of the element having specified name as a double value

Same as calling asElement().Element.getElementAsFloat64(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a double value

getElementAsFloat32

public abstract float getElementAsFloat32(Name name)
Return the value of the element having specified name as a float value

Same as calling asElement().Element.getElementAsFloat32(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a float value

getElementAsFloat32

public abstract float getElementAsFloat32(java.lang.String name)
Return the value of the element having specified name as a float value

Same as calling asElement().Element.getElementAsFloat32(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a float value

getElementAsString

public abstract java.lang.String getElementAsString(Name name)
Return the value of the element having specified name as a String value

Same as calling asElement().Element.getElementAsString(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a String value

getElementAsString

public abstract java.lang.String getElementAsString(java.lang.String name)
Return the value of the element having specified name as a String value

Same as calling asElement().Element.getElementAsString(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a String value

getElementAsDatetime

public abstract Datetime getElementAsDatetime(Name name)
Return the value of the element having specified name as a Datetime value

Same as calling asElement().Element.getElementAsDatetime(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a Datetime value

getElementAsDatetime

public abstract Datetime getElementAsDatetime(java.lang.String name)
Return the value of the element having specified name as a Datetime value

Same as calling asElement().Element.getElementAsDatetime(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a Datetime value

getElementAsDate

public abstract Datetime getElementAsDate(Name name)
Return the value of the element having specified name as a Date value

Same as calling asElement().Element.getElementAsDate(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a Date value

getElementAsDate

public abstract Datetime getElementAsDate(java.lang.String name)
Return the value of the element having specified name as a Date value

Same as calling asElement().Element.getElementAsDate(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a Date value

getElementAsTime

public abstract Datetime getElementAsTime(Name name)
Return the value of the element having specified name as a Time value

Same as calling asElement().Element.getElementAsTime(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a Time value

getElementAsTime

public abstract Datetime getElementAsTime(java.lang.String name)
Return the value of the element having specified name as a Time value

Same as calling asElement().Element.getElementAsTime(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a Time value

getElementAsName

public abstract Name getElementAsName(Name name)
Return the value of the element having specified name as a Constant value

Same as calling asElement().Element.getElementAsName(Name)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a Time value

getElementAsName

public abstract Name getElementAsName(java.lang.String name)
Return the value of the element having specified name as a Constant value

Same as calling asElement().Element.getElementAsName(String)

Throws:
NotFoundException - if this message does not contain an element having the specified name
InvalidConversionException - if the value is not convertible to a Time value

toString

public abstract java.lang.String toString()
Returns the contents of this message as a String

Overrides:
toString in class java.lang.Object

print

public abstract void print(java.io.OutputStream output)
                    throws java.io.IOException
Prints the contents of this message to OutputStream.

Throws:
java.io.IOException

print

public abstract void print(java.io.Writer writer)
                    throws java.io.IOException
Prints the contents of this message to Writer.

Throws:
java.io.IOException


Copyright © 2015 Bloomberg L.P.. All Rights Reserved.