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
ConstructorDescriptionEventFormatter
(Event event) Creates anEventFormatter
to add messages to the specified event. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Append an empty complex element of the appropriate type to the element which represents an array ofElement
type.void
appendMessage
(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
.void
appendMessage
(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
.void
appendMessage
(String messageType, Topic topic) Deprecated.void
appendMessage
(String messageType, Topic topic, Integer sequenceNumber) Deprecated.Use {appendMessage(Name, Topic, Integer)
} instead.void
appendRecapMessage
(Topic topic, CorrelationID cid) Append a (empty) recap message that will be published under the specified 'topic' to the event referenced by thisEventFormatter
.void
appendRecapMessage
(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
.void
appendResponse
(Name operationName) Append an (empty) response message of the specifiedoperationName
that will be sent in response to the previously received operation request.void
appendResponse
(String operationName) Deprecated.Use {appendResponse(Name)
instead.void
appendValue
(boolean value) Append the specified 'value' to the element which represents an array ofboolean
type.void
appendValue
(char value) Append the specified 'value' to the element which represents an array ofchar
type.void
appendValue
(double value) Append the specified 'value' to the element which represents an array ofdouble
type.void
appendValue
(float value) Append the specified 'value' to the element which represents an array offloat
type.void
appendValue
(int value) Append the specified 'value' to the element which represents an array ofint
type.void
appendValue
(long value) Append the specified 'value' to the element which represents an array oflong
type.void
appendValue
(Datetime value) Append the specified 'value' to the element which represents an array ofDatetime
type.void
appendValue
(Name value) Append the specified 'value' to the element which represents an array ofName
type.void
appendValue
(String value) Append the specified 'value' to the element which represents an array ofString
type.void
Returns this formatter's context back to the location where it was before the most recent call topushElement(java.lang.String)
or {appendElement()
.void
pushElement
(Name name) Changes the level at which thisEventFormatter
is operating to the specified element 'name'.void
pushElement
(String name) Deprecated.Use {pushElement(Name)
instead.void
setElement
(Name name, boolean value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(Name name, byte[] value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(Name name, char value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(Name name, double value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(Name name, float value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(Name name, int value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(Name name, long value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(Name name, Datetime value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(Name name, Name value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(Name name, String value) Sets the element with the specifiedname
within the current element to the specifiedvalue
.void
setElement
(String name, boolean value) Deprecated.Use {setElement(Name, boolean)
instead.void
setElement
(String name, char value) Deprecated.Use {setElement(Name, char)
instead.void
setElement
(String name, double value) Deprecated.Use {setElement(Name, double)
instead.void
setElement
(String name, float value) Deprecated.Use {setElement(Name, float)
instead.void
setElement
(String name, int value) Deprecated.Use {setElement(Name, int)
instead.void
setElement
(String name, long value) Deprecated.Use {setElement(Name, long)
instead.void
setElement
(String name, Datetime value) Deprecated.Use {setElement(Name, Datetime)
instead.void
setElement
(String name, Name value) Deprecated.Use {setElement(Name, Name)
instead.void
setElement
(String name, String value) Deprecated.Use {setElement(Name, String)
instead.void
setElementNull
(Name name) Creates a null element with the specified 'name'.void
setElementNull
(String name) Deprecated.Use {setElementNull(Name)
instead.
-
Constructor Details
-
EventFormatter
Creates anEventFormatter
to add messages to the specified event. The behavior is undefined if the specified event already has anotherEventFormatter
attached.- 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 aTopicRecap
message. 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 theTopicRecap
message 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 aTopicRecap
message. 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 theTopicRecap
message 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 aName
object with the specifiedoperationName
value.Note that using
Name
overloads is preferable, as theName
objects 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 specifiedoperationName
that 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 theEvent
is 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 ofboolean
type.- Parameters:
value
- the value to be added
-
appendValue
public void appendValue(char value) Append the specified 'value' to the element which represents an array ofchar
type.- Parameters:
value
- the value to be added
-
appendValue
public void appendValue(int value) Append the specified 'value' to the element which represents an array ofint
type.- Parameters:
value
- the value to be added
-
appendValue
public void appendValue(long value) Append the specified 'value' to the element which represents an array oflong
type.- Parameters:
value
- the value to be added
-
appendValue
public void appendValue(float value) Append the specified 'value' to the element which represents an array offloat
type.- Parameters:
value
- the value to be added
-
appendValue
public void appendValue(double value) Append the specified 'value' to the element which represents an array ofdouble
type.- Parameters:
value
- the value to be added
-
appendValue
Append the specified 'value' to the element which represents an array ofDatetime
type.- Parameters:
value
- the value to be added
-
appendValue
Append the specified 'value' to the element which represents an array ofString
type.- Parameters:
value
- the value to be added
-
appendValue
Append the specified 'value' to the element which represents an array ofName
type.- 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 ofElement
type. -
pushElement
Deprecated.Use {pushElement(Name)
instead.Changes the level at which thisEventFormatter
is operating to the specified element 'name'. After this returns the context of theEventFormatter
is 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 thisEventFormatter
is operating to the specified element 'name'. After this returns the context of theEventFormatter
is 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 specifiedname
within the current element to the specifiedvalue
. The behavior of this function is undefined ifvalue
isnull
. 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, Name)
instead.Sets the element with the specifiedname
within the current element to the specifiedvalue
. The behavior of this function is undefined ifvalue
isnull
. 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, boolean)
instead.Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, char)
instead.Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, int)
instead.Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, long)
instead.Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, float)
instead.Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, double)
instead.Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within the current element to the specifiedvalue
. The behavior of this function is undefined ifvalue
isnull
. 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within the current element to the specifiedvalue
. The behavior of this function is undefined ifvalue
isnull
. 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Deprecated.Use {setElement(Name, Datetime)
instead.Sets the element with the specifiedname
within the current element to the specifiedvalue
. The behavior of this function is undefined ifvalue
isnull
. 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within the current element to the specifiedvalue
. The behavior of this function is undefined ifvalue
isnull
. 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
setElement
Sets the element with the specifiedname
within the current element to the specifiedvalue
. The behavior of this function is undefined ifvalue
isnull
. 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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-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 aname
sub-element of the current sequence or choice element or if the element identified byname
has already been setInvalidConversionException
- ifvalue
cannot be converted to the type specified by the schema for thename
sub-elementIllegalStateException
- if the operating stack is empty
-
appendMessage(Name, Topic)
} instead.