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
- A message formatted with
formatMessageXml(java.lang.String)
is further formatted. - A message formatted with a
set
method or anappend
method is further formatted usingformatMessageXml(java.lang.String)
.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Creates an array element and appends it to the element on which thisMessageFormatter
is operating on.void
appendValue
(boolean value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating.void
appendValue
(char value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating.void
appendValue
(double value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating.void
appendValue
(float value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating.void
appendValue
(int value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating.void
appendValue
(long value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating.void
appendValue
(Datetime value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating.void
appendValue
(Name value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating.void
appendValue
(String value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating.void
formatMessageXml
(String message) Formats the message from itsXML
representation.void
Undoes the most recent call topushElement(com.bloomberglp.blpapi.Name)
on thisMessageFormatter
and returns the context of theMessageFormatter
to where it was before the call topushElement(com.bloomberglp.blpapi.Name)
.void
pushElement
(Name name) Changes the level at which thisMessageFormatter
is operating to the specified elementname
.void
setElement
(Name name, boolean value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElement
(Name name, byte[] value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElement
(Name name, char value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElement
(Name name, double value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElement
(Name name, float value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElement
(Name name, int value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElement
(Name name, long value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElement
(Name name, Datetime value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElement
(Name name, Name value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElement
(Name name, String value) Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
.void
setElementNull
(Name name) Creates a null element with the specifiedname
.
-
Method Details
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.- Parameters:
name
- name of the element.value
- the value to be set.- Throws:
IllegalArgumentException
- ifname
is null.
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.- Parameters:
name
- name of the element.value
- the value to be set.- Throws:
IllegalArgumentException
- ifname
is null.
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.- Parameters:
name
- name of the element.value
- the value to be set.- Throws:
IllegalArgumentException
- ifname
is null.
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.- Parameters:
name
- name of the element.value
- the value to be set.- Throws:
IllegalArgumentException
- ifname
is null.
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.- Parameters:
name
- name of the element.value
- the value to be set.- Throws:
IllegalArgumentException
- ifname
is null.
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.- Parameters:
name
- name of the element.value
- the value to be set.- Throws:
IllegalArgumentException
- ifname
is null.
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.- Parameters:
name
- name of the element.value
- the value to be set.- Throws:
IllegalArgumentException
- ifname
is null orvalue
is null.
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message, or if the element identified byname
has already been set, an exception is thrown.The behavior is undefined unless
value
is notnull
.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
- ifname
is null orvalue
is null.
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.The behavior is undefined unless
value
is notnull
.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
- ifname
is null orvalue
is null.
-
setElement
Sets the element with the specifiedname
to the specifiedvalue
in the current message referenced by thisMessageFormatter
. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.- Parameters:
name
- name of the element.value
- the value to be set.- Throws:
IllegalArgumentException
- ifname
is null orvalue
is null.
-
setElementNull
Creates a null element with the specifiedname
. 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 thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.- Parameters:
name
- name of the element.- Throws:
IllegalArgumentException
- ifname
is null.
-
pushElement
Changes the level at which thisMessageFormatter
is operating to the specified elementname
. The elementname
must identify either a choice, a sequence or an array at the current level of the schema or the behavior is undefined. If thename
is invalid for the current message or if the element identified byname
has already been set, an exception is thrown.After this returns, the context of the
MessageFormatter
is set to the elementname
in the schema and any calls tosetElement(com.bloomberglp.blpapi.Name, boolean)
orpushElement(com.bloomberglp.blpapi.Name)
are applied at that level.If
name
represents an array of scalars thenappendValue(boolean)
must be used to add values.If
name
represents an array of complex types thenappendElement()
creates the first entry and sets the context of theMessageFormatter
to that element. CallingappendElement()
again will create another entry.- Parameters:
name
- name of the element.- Throws:
IllegalArgumentException
- ifname
is null.
-
popElement
void popElement()Undoes the most recent call topushElement(com.bloomberglp.blpapi.Name)
on thisMessageFormatter
and returns the context of theMessageFormatter
to where it was before the call topushElement(com.bloomberglp.blpapi.Name)
. OncepopElement()
has been called it is invalid to attempt to re-visit the same context. -
appendValue
void appendValue(boolean value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating. Throws an exception if the schema of the message is flat or the current element to whichvalue
is appended is not an array.- Parameters:
value
- the value to be appended to this array.
-
appendValue
void appendValue(char value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating. Throws an exception if the schema of the message is flat or the current element to whichvalue
is appended is not an array.- Parameters:
value
- the value to be appended to this array.
-
appendValue
void appendValue(int value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating. Throws an exception if the schema of the message is flat or the current element to whichvalue
is appended is not an array.- Parameters:
value
- the value to be appended to this array.
-
appendValue
void appendValue(long value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating. Throws an exception if the schema of the message is flat or the current element to whichvalue
is appended is not an array.- Parameters:
value
- the value to be appended to this array.
-
appendValue
void appendValue(float value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating. Throws an exception if the schema of the message is flat or the current element to whichvalue
is appended is not an array.- Parameters:
value
- the value to be appended to this array.
-
appendValue
void appendValue(double value) Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating. Throws an exception if the schema of the message is flat or the current element to whichvalue
is appended is not an array.- Parameters:
value
- the value to be appended to this array.
-
appendValue
Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating. Throws an exception if the schema of the message is flat or the current element to whichvalue
is appended is not an array.- Parameters:
value
- the value to be appended to this array.- Throws:
IllegalArgumentException
- ifvalue
is null.
-
appendValue
Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating. Throws an exception if the schema of the message is flat or the current element to whichvalue
is appended is not an array.- Parameters:
value
- the value to be appended to this array.- Throws:
IllegalArgumentException
- ifvalue
is null.
-
appendValue
Appends the specifiedvalue
to the element on which thisMessageFormatter
is operating. Throws an exception if the schema of the message is flat or the current element to whichvalue
is appended is not an array.- Parameters:
value
- the value to be appended to this array.- Throws:
IllegalArgumentException
- ifvalue
is null.
-
appendElement
void appendElement()Creates an array element and appends it to the element on which thisMessageFormatter
is operating on. Throws an exception if the schema of the message is flat. -
formatMessageXml
Formats the message from itsXML
representation. An exception is thrown if the method fails to format the message. The behavior is undefined if further formatting is done using thisMessageFormatter
.- Parameters:
message
-XML
representation of the message.- Throws:
IllegalArgumentException
- ifmessage
is null.
-