Class EventFormatter
ProviderSession
requests.
An EventFormatter is created either from an Event obtained from Service.createPublishEvent() or from Service.createResponseEvent(CorrelationID). Once
one or more Messages have been appended to the Event using the EventFormatter the Event can be
published using ProviderSession.publish(Event) or sent back as a response using ProviderSession.sendResponse(Event).
EventFormatter objects cannot be copied or assigned so as to ensure there is no ambiguity about what happens if two EventFormatters are both formatting the same Event.
An EventFormatter object supports writing once only to each field. It is an error to call setElement() or pushElement() for the same name more than once at a particular level of the schema when creating a message.
-
Constructor Summary
ConstructorsConstructorDescriptionEventFormatter(Event event) Creates anEventFormatterto add messages to the specified event. -
Method Summary
Modifier and TypeMethodDescriptionvoidAppend an empty complex element of the appropriate type to the element which represents an array ofElementtype.voidappendMessage(Name messageType, Topic topic) Appends a (empty) message of the specified 'messageType' that will be published under the specified 'topic' to the event referenced by thisEventFormatter.voidappendMessage(Name messageType, Topic topic, Integer sequenceNumber) Appends a (empty) message of the specified 'messageType' that will be published under the specified 'topic' with the specified 'sequenceNumber' to the event referenced by thisEventFormatter.voidappendMessage(String messageType, Topic topic) Deprecated.voidappendMessage(String messageType, Topic topic, Integer sequenceNumber) Deprecated.Use {appendMessage(Name, Topic, Integer)} instead.voidappendRecapMessage(Topic topic, CorrelationID cid) Append a (empty) recap message that will be published under the specified 'topic' to the event referenced by thisEventFormatter.voidappendRecapMessage(Topic topic, Integer sequenceNumber, CorrelationID cid) Append a (empty) recap message that will be published under the specified 'topic' to the event referenced by thisEventFormatter.voidappendResponse(Name operationName) Append an (empty) response message of the specifiedoperationNamethat will be sent in response to the previously received operation request.voidappendResponse(String operationName) Deprecated.Use {appendResponse(Name)instead.voidappendValue(boolean value) Append the specified 'value' to the element which represents an array ofbooleantype.voidappendValue(char value) Append the specified 'value' to the element which represents an array ofchartype.voidappendValue(double value) Append the specified 'value' to the element which represents an array ofdoubletype.voidappendValue(float value) Append the specified 'value' to the element which represents an array offloattype.voidappendValue(int value) Append the specified 'value' to the element which represents an array ofinttype.voidappendValue(long value) Append the specified 'value' to the element which represents an array oflongtype.voidappendValue(Datetime value) Append the specified 'value' to the element which represents an array ofDatetimetype.voidappendValue(Name value) Append the specified 'value' to the element which represents an array ofNametype.voidappendValue(String value) Append the specified 'value' to the element which represents an array ofStringtype.voidReturns this formatter's context back to the location where it was before the most recent call topushElement(java.lang.String)or {appendElement().voidpushElement(Name name) Changes the level at which thisEventFormatteris operating to the specified element 'name'.voidpushElement(String name) Deprecated.Use {pushElement(Name)instead.voidsetElement(Name name, boolean value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(Name name, byte[] value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(Name name, char value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(Name name, double value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(Name name, float value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(Name name, int value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(Name name, long value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(Name name, Datetime value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(Name name, Name value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(Name name, String value) Sets the element with the specifiednamewithin the current element to the specifiedvalue.voidsetElement(String name, boolean value) Deprecated.Use {setElement(Name, boolean)instead.voidsetElement(String name, char value) Deprecated.Use {setElement(Name, char)instead.voidsetElement(String name, double value) Deprecated.Use {setElement(Name, double)instead.voidsetElement(String name, float value) Deprecated.Use {setElement(Name, float)instead.voidsetElement(String name, int value) Deprecated.Use {setElement(Name, int)instead.voidsetElement(String name, long value) Deprecated.Use {setElement(Name, long)instead.voidsetElement(String name, Datetime value) Deprecated.Use {setElement(Name, Datetime)instead.voidsetElement(String name, Name value) Deprecated.Use {setElement(Name, Name)instead.voidsetElement(String name, String value) Deprecated.Use {setElement(Name, String)instead.voidsetElementNull(Name name) Creates a null element with the specified 'name'.voidsetElementNull(String name) Deprecated.Use {setElementNull(Name)instead.
-
Constructor Details
-
EventFormatter
Creates anEventFormatterto add messages to the specified event. The behavior is undefined if the specified event already has anotherEventFormatterattached.- Parameters:
event- the event to be formatted
-
-
Method Details
-
appendMessage
Deprecated.Use {appendMessage(Name, Topic)} instead.Appends a (empty) message of the specified 'messageType' that will be published under the specified 'topic' to the event referenced by thisEventFormatter. After a message has been appended its elements can be set using the varioussetElement(java.lang.String,java.lang.String)methods.- Parameters:
messageType- the name of the message type that needs to be addedtopic- the corresponding topic
-
appendMessage
Deprecated.Use {appendMessage(Name, Topic, Integer)} instead.Appends a (empty) message of the specified 'messageType' that will be published under the specified 'topic' with the specified 'sequenceNumber' to the event referenced by thisEventFormatter. After a message has been appended its elements can be set using the varioussetElement(java.lang.String, java.lang.String)methods. The behavior is undefined unless the 'sequenceNumber' is greater (unless the value wrapped) than the last value used in any previous message on this 'topic'.- Parameters:
messageType- the name of the message type that needs to be addedtopic- the corresponding topicsequenceNumber- the sequence number for this message
-
appendMessage
Appends a (empty) message of the specified 'messageType' that will be published under the specified 'topic' to the event referenced by thisEventFormatter. After a message has been appended its elements can be set using the varioussetElement(java.lang.String, java.lang.String)methods.- Parameters:
messageType- the name of the message type that needs to be addedtopic- the corresponding topic
-
appendMessage
Appends a (empty) message of the specified 'messageType' that will be published under the specified 'topic' with the specified 'sequenceNumber' to the event referenced by thisEventFormatter. After a message has been appended its elements can be set using the varioussetElement(java.lang.String, java.lang.String)methods. The behavior is undefined unless the 'sequenceNumber' is greater (unless the value wrapped) than the last value used in any previous message on this 'topic'.- Parameters:
messageType- the name of the message type that needs to be addedtopic- the corresponding topicsequenceNumber- the sequence number for this message
-
appendRecapMessage
Append a (empty) recap message that will be published under the specified 'topic' to the event referenced by thisEventFormatter. Specify the optional 'cid' if this recap message is added in response to aTopicRecapmessage. After a message has been appended its elements can be set using the varioussetElement(java.lang.String, java.lang.String)methods. It is an error to append a recap message to an admin event.- Parameters:
topic- the corresponding topiccid- the correlationId of theTopicRecapmessage if responding to a recap request or null if this is a recap message for all subscribers
-
appendRecapMessage
Append a (empty) recap message that will be published under the specified 'topic' to the event referenced by thisEventFormatter. Specify the optional 'cid' if this recap message is added in response to aTopicRecapmessage. After a message has been appended its elements can be set using the varioussetElement(java.lang.String, java.lang.String)methods. It is an error to create append a recap message to an admin event. The behavior is undefined unless the 'sequenceNumber' is greater (unless the value wrapped) than the last value used in any previous message on this 'topic'.- Parameters:
topic- the corresponding topicsequenceNumber- the sequence number for this messagecid- the correlationId of theTopicRecapmessage if responding to a recap request or null if this is a recap message for all subscribers
-
appendResponse
Deprecated.Use {appendResponse(Name)instead.Equivalent toappendResponse(Name operationName)with aNameobject with the specifiedoperationNamevalue.Note that using
Nameoverloads is preferable, as theNameobjects have better performance if they are re-used after being created.- Parameters:
operationName- name of the operation whose response type is to be used
-
appendResponse
Append an (empty) response message of the specifiedoperationNamethat will be sent in response to the previously received operation request. After a message has been appended its elements can be set using the varioussetElement(java.lang.String, java.lang.String)methods. Only one response can be appended to an event. The behavior is undefined unless theEventis currently empty.- Parameters:
operationName- name of the operation whose response type is to be used
-
appendValue
public void appendValue(boolean value) Append the specified 'value' to the element which represents an array ofbooleantype.- Parameters:
value- the value to be added
-
appendValue
public void appendValue(char value) Append the specified 'value' to the element which represents an array ofchartype.- Parameters:
value- the value to be added
-
appendValue
public void appendValue(int value) Append the specified 'value' to the element which represents an array ofinttype.- Parameters:
value- the value to be added
-
appendValue
public void appendValue(long value) Append the specified 'value' to the element which represents an array oflongtype.- Parameters:
value- the value to be added
-
appendValue
public void appendValue(float value) Append the specified 'value' to the element which represents an array offloattype.- Parameters:
value- the value to be added
-
appendValue
public void appendValue(double value) Append the specified 'value' to the element which represents an array ofdoubletype.- Parameters:
value- the value to be added
-
appendValue
Append the specified 'value' to the element which represents an array ofDatetimetype.- Parameters:
value- the value to be added
-
appendValue
Append the specified 'value' to the element which represents an array ofStringtype.- Parameters:
value- the value to be added
-
appendValue
Append the specified 'value' to the element which represents an array ofNametype.- Parameters:
value- the value to be added
-
appendElement
public void appendElement()Append an empty complex element of the appropriate type to the element which represents an array ofElementtype. -
pushElement
Deprecated.Use {pushElement(Name)instead.Changes the level at which thisEventFormatteris operating to the specified element 'name'. After this returns the context of theEventFormatteris set to the element 'name' in the schema and subsequent calls tosetElement(java.lang.String, java.lang.String)orpushElement(java.lang.String)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 the formatter to that element. CallingappendElement()again will create another entry.- Parameters:
name- the name of sub-element- Throws:
NotFoundException- if the name does not identify a sub-element at the current level of the schema
-
pushElement
Changes the level at which thisEventFormatteris operating to the specified element 'name'. After this returns the context of theEventFormatteris set to the element 'name' in the schema and subsequent calls tosetElement(java.lang.String, java.lang.String)orpushElement(java.lang.String)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 the formatter to that element. CallingappendElement()again will create another entry.- Parameters:
name- the name of sub-element- Throws:
NotFoundException- if the name does not identify a sub-element at the current level of the schema
-
popElement
public void popElement()Returns this formatter's context back to the location where it was before the most recent call topushElement(java.lang.String)or {appendElement(). -
setElement
Deprecated.Use {setElement(Name, String)instead.Sets the element with the specifiednamewithin the current element to the specifiedvalue. The behavior of this function is undefined ifvalueisnull. Note that this function is not intended for publication of null values; usesetElementNull(String)instead.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, Name)instead.Sets the element with the specifiednamewithin the current element to the specifiedvalue. The behavior of this function is undefined ifvalueisnull. Note that this function is not intended for publication of null values; usesetElementNull(String)instead.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, boolean)instead.Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, char)instead.Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, int)instead.Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, long)instead.Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, float)instead.Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, double)instead.Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue. The behavior of this function is undefined ifvalueisnull. Note that this function is not intended for publication of null values; usesetElementNull(Name)instead.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue. The behavior of this function is undefined ifvalueisnull. Note that this function is not intended for publication of null values; usesetElementNull(Name)instead.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, Datetime)instead.Sets the element with the specifiednamewithin the current element to the specifiedvalue. The behavior of this function is undefined ifvalueisnull. Note that this function is not intended for publication of null values; usesetElementNull(String)instead.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue. The behavior of this function is undefined ifvalueisnull. Note that this function is not intended for publication of null values; usesetElementNull(Name)instead.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElement
Sets the element with the specifiednamewithin the current element to the specifiedvalue. The behavior of this function is undefined ifvalueisnull. Note that this function is not intended for publication of null values; usesetElementNull(Name)instead.- Parameters:
name- the name of subfieldvalue- the value to be set- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElementNull
Deprecated.Use {setElementNull(Name)instead.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 schema configuration.- Parameters:
name- the name of subfield to be nulled- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
setElementNull
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 schema configuration.- Parameters:
name- the name of subfield to be nulled- Throws:
UnsupportedOperationException- if the current element is not a sequence or choiceNotFoundException- if the schema does not identify anamesub-element of the current sequence or choice element or if the element identified bynamehas already been setInvalidConversionException- ifvaluecannot be converted to the type specified by the schema for thenamesub-elementIllegalStateException- if the operating stack is empty
-
appendMessage(Name, Topic)} instead.