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
setmethod or anappendmethod is further formatted usingformatMessageXml(java.lang.String).
-
Method Summary
Modifier and TypeMethodDescriptionvoidCreates an array element and appends it to the element on which thisMessageFormatteris operating on.voidappendValue(boolean value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating.voidappendValue(char value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating.voidappendValue(double value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating.voidappendValue(float value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating.voidappendValue(int value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating.voidappendValue(long value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating.voidappendValue(Datetime value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating.voidappendValue(Name value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating.voidappendValue(String value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating.voidformatMessageXml(String message) Formats the message from itsXMLrepresentation.voidUndoes the most recent call topushElement(com.bloomberglp.blpapi.Name)on thisMessageFormatterand returns the context of theMessageFormatterto where it was before the call topushElement(com.bloomberglp.blpapi.Name).voidpushElement(Name name) Changes the level at which thisMessageFormatteris operating to the specified elementname.voidsetElement(Name name, boolean value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElement(Name name, byte[] value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElement(Name name, char value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElement(Name name, double value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElement(Name name, float value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElement(Name name, int value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElement(Name name, long value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElement(Name name, Datetime value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElement(Name name, Name value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElement(Name name, String value) Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter.voidsetElementNull(Name name) Creates a null element with the specifiedname.
-
Method Details
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.- Parameters:
name- name of the element.value- the value to be set.- Throws:
IllegalArgumentException- ifnameis null.
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.- Parameters:
name- name of the element.value- the value to be set.- Throws:
IllegalArgumentException- ifnameis null.
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.- Parameters:
name- name of the element.value- the value to be set.- Throws:
IllegalArgumentException- ifnameis null.
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.- Parameters:
name- name of the element.value- the value to be set.- Throws:
IllegalArgumentException- ifnameis null.
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.- Parameters:
name- name of the element.value- the value to be set.- Throws:
IllegalArgumentException- ifnameis null.
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.- Parameters:
name- name of the element.value- the value to be set.- Throws:
IllegalArgumentException- ifnameis null.
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.- Parameters:
name- name of the element.value- the value to be set.- Throws:
IllegalArgumentException- ifnameis null orvalueis null.
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message, or if the element identified bynamehas already been set, an exception is thrown.The behavior is undefined unless
valueis 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- ifnameis null orvalueis null.
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.The behavior is undefined unless
valueis 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- ifnameis null orvalueis null.
-
setElement
Sets the element with the specifiednameto the specifiedvaluein the current message referenced by thisMessageFormatter. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.- Parameters:
name- name of the element.value- the value to be set.- Throws:
IllegalArgumentException- ifnameis null orvalueis 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 thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.- Parameters:
name- name of the element.- Throws:
IllegalArgumentException- ifnameis null.
-
pushElement
Changes the level at which thisMessageFormatteris operating to the specified elementname. The elementnamemust identify either a choice, a sequence or an array at the current level of the schema or the behavior is undefined. If thenameis invalid for the current message or if the element identified bynamehas already been set, an exception is thrown.After this returns, the context of the
MessageFormatteris set to the elementnamein the schema and any calls tosetElement(com.bloomberglp.blpapi.Name, boolean)orpushElement(com.bloomberglp.blpapi.Name)are applied at that level.If
namerepresents an array of scalars thenappendValue(boolean)must be used to add values.If
namerepresents an array of complex types thenappendElement()creates the first entry and sets the context of theMessageFormatterto that element. CallingappendElement()again will create another entry.- Parameters:
name- name of the element.- Throws:
IllegalArgumentException- ifnameis null.
-
popElement
void popElement()Undoes the most recent call topushElement(com.bloomberglp.blpapi.Name)on thisMessageFormatterand returns the context of theMessageFormatterto 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 specifiedvalueto the element on which thisMessageFormatteris operating. Throws an exception if the schema of the message is flat or the current element to whichvalueis appended is not an array.- Parameters:
value- the value to be appended to this array.
-
appendValue
void appendValue(char value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating. Throws an exception if the schema of the message is flat or the current element to whichvalueis appended is not an array.- Parameters:
value- the value to be appended to this array.
-
appendValue
void appendValue(int value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating. Throws an exception if the schema of the message is flat or the current element to whichvalueis appended is not an array.- Parameters:
value- the value to be appended to this array.
-
appendValue
void appendValue(long value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating. Throws an exception if the schema of the message is flat or the current element to whichvalueis appended is not an array.- Parameters:
value- the value to be appended to this array.
-
appendValue
void appendValue(float value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating. Throws an exception if the schema of the message is flat or the current element to whichvalueis appended is not an array.- Parameters:
value- the value to be appended to this array.
-
appendValue
void appendValue(double value) Appends the specifiedvalueto the element on which thisMessageFormatteris operating. Throws an exception if the schema of the message is flat or the current element to whichvalueis appended is not an array.- Parameters:
value- the value to be appended to this array.
-
appendValue
Appends the specifiedvalueto the element on which thisMessageFormatteris operating. Throws an exception if the schema of the message is flat or the current element to whichvalueis appended is not an array.- Parameters:
value- the value to be appended to this array.- Throws:
IllegalArgumentException- ifvalueis null.
-
appendValue
Appends the specifiedvalueto the element on which thisMessageFormatteris operating. Throws an exception if the schema of the message is flat or the current element to whichvalueis appended is not an array.- Parameters:
value- the value to be appended to this array.- Throws:
IllegalArgumentException- ifvalueis null.
-
appendValue
Appends the specifiedvalueto the element on which thisMessageFormatteris operating. Throws an exception if the schema of the message is flat or the current element to whichvalueis appended is not an array.- Parameters:
value- the value to be appended to this array.- Throws:
IllegalArgumentException- ifvalueis null.
-
appendElement
void appendElement()Creates an array element and appends it to the element on which thisMessageFormatteris operating on. Throws an exception if the schema of the message is flat. -
formatMessageXml
Formats the message from itsXMLrepresentation. 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-XMLrepresentation of the message.- Throws:
IllegalArgumentException- ifmessageis null.
-