public interface AdaptrisMessage extends InterlokMessage
Represents a message in the framework.
Modifier and Type | Method and Description |
---|---|
void |
addEvent(MessageEventGenerator meg,
boolean wasSuccessful)
Adds an event to this
AdaptrisMessage 's
MessageLifecycleEvent . |
void |
addMetadata(MetadataElement metadata)
Puts the passed
MetadataElement into the metadata. |
void |
addMetadata(java.lang.String key,
java.lang.String value)
Puts the passed
value into the metadata against the passed
key . |
default void |
addObjectMetadata(java.lang.String key,
java.lang.Object object)
Deprecated.
since 3.0.6 use
InterlokMessage.addObjectHeader(Object, Object) instead. |
void |
clearMetadata()
Clears the current metadata.
|
java.lang.Object |
clone()
Returns a deep clone of this object.
|
default boolean |
containsKey(java.lang.String key)
Deprecated.
since 3.0.6 use
InterlokMessage.headersContainsKey(String) instead. |
byte[] |
encode(AdaptrisMessageEncoder encoder)
Uses the passed
AdaptrisMessageEncoder to create an encoded
version of this AdaptrisMessage . |
boolean |
equivalentForTracking(AdaptrisMessage other)
AdaptrisMessage 's are equivalent for tracking if they
have the same unique Id, their payloads are equal, their char encodings are
equal and their metadata is equal. |
default java.lang.String |
getCharEncoding()
Deprecated.
since 3.0.6 use {
InterlokMessage.getContentEncoding() instead. |
AdaptrisMessageFactory |
getFactory()
Return the factory that created this message.
|
MessageLifecycleEvent |
getMessageLifecycleEvent()
Returns this object's
MessageLifecycleEvent . |
java.util.Set<MetadataElement> |
getMetadata()
Returns a shallow clone of this message's metadata.
|
MetadataElement |
getMetadata(java.lang.String key)
Returns the
MetadataElement containing the passed
key or null if the key does not
exist. |
java.lang.String |
getMetadataValue(java.lang.String key)
Returns the
String value associated with the passed
key or null if the key does not
exist. |
java.lang.String |
getMetadataValueIgnoreKeyCase(java.lang.String key)
First looks for a metadata value stored against the passed key taking
account of the passed key's case.
|
java.lang.String |
getNextServiceId()
Returns the unique ID of the next
Service to apply to the
message. |
default java.util.Map |
getObjectMetadata()
Deprecated.
since 3.0.6 use
InterlokMessage.getObjectHeaders() instead. |
byte[] |
getPayload()
Returns a copy of this message's payload in its raw,
byte[] form. |
default java.lang.String |
getPayloadForLogging() |
long |
getSize()
Return the size of the payload.
|
default java.lang.String |
getStringPayload()
Deprecated.
since 3.0.6 use {
InterlokMessage.getContent() instead. |
void |
removeMetadata(MetadataElement element)
Removes the passed
MetadataElement from the metadata if it is
present. |
default void |
setCharEncoding(java.lang.String charEncoding)
Deprecated.
since 3.0.6 use {
InterlokMessage.setContentEncoding(String) instead. |
void |
setMetadata(java.util.Set<MetadataElement> metadata)
Adds all the passed metadata to this message's metadata.
|
void |
setNextServiceId(java.lang.String uniqueId)
Sets the unique ID of the next
Service to apply to the
message. |
void |
setPayload(byte[] payload)
Sets the passed
byte[] as this message's payload. |
default void |
setStringPayload(java.lang.String payload)
Deprecated.
you should use
setStringPayload(String, String) and formally declare the encoding you wish to use for this
string; since 2.9.3 |
default void |
setStringPayload(java.lang.String payload,
java.lang.String charEncoding)
Deprecated.
since 3.0.6 Use
InterlokMessage.setContent(String, String) |
addMessageHeader, addObjectHeader, getContent, getContentEncoding, getInputStream, getMessageHeaders, getObjectHeaders, getOutputStream, getReader, getUniqueId, getWriter, getWriter, headersContainsKey, removeMessageHeader, resolve, resolve, setContent, setContentEncoding, setMessageHeaders, setUniqueId, wrap
void setPayload(byte[] payload)
Sets the passed byte[]
as this message's payload.
payload
- the payloadbyte[] getPayload()
Returns a copy of this message's payload in its raw,
byte[]
form.
byte[]
formlong getSize()
@Deprecated default void setStringPayload(java.lang.String payload)
setStringPayload(String, String)
and formally declare the encoding you wish to use for this
string; since 2.9.3
Sets the passed String
as the payload. The passed String
is assumed to have the default platform
encoding and any previously set character encoding will be set to null. If a specific character encoding is required use
setStringPayload(String, String)
.
payload
- the payload to set@Deprecated default void setStringPayload(java.lang.String payload, java.lang.String charEncoding)
InterlokMessage.setContent(String, String)
Sets the passed String
with the passed character encoding as
the payload. Passing null for charEncoding
is the same as
using setPayload(String)
.
payload
- the payloadcharEncoding
- the character encoding used by the payload@Deprecated default java.lang.String getStringPayload()
InterlokMessage.getContent()
instead.
Returns a String
representation of the payload. This
String
will be created using the provided character encoding
if one has been set, otherwise the default platform character encoding will
be used. If you wish to apply a different character encoding use
getPayload
to obtain a raw byte[]
.
String
representation of the payload@Deprecated default void setCharEncoding(java.lang.String charEncoding)
InterlokMessage.setContentEncoding(String)
instead.Sets the character encoding associated with the payload. If a character encoding is not explicitly set using this method, implementations are expected to use the default platform character encoding.
charEncoding
- the character encoding associated with the payload.@Deprecated default java.lang.String getCharEncoding()
InterlokMessage.getContentEncoding()
instead.
Returns this message's character encoding, if one has been explicitly set,
otherwise null
.
null
java.lang.String getMetadataValue(java.lang.String key)
Returns the String
value associated with the passed
key
or null
if the key
does not
exist. NB may also return null
if null
was
explicitly set as the value of the key. Use containsKey
to
differentiate these cases.
key
- the key to look forMetadataElement getMetadata(java.lang.String key)
Returns the MetadataElement
containing the passed
key
or null
if the key
does not
exist. NB may also return null
if null
was
explicitly set as the value of the key. Use containsKey
to
differentiate these cases.
key
- the key to look forMetadataElement
containing the key@Deprecated default boolean containsKey(java.lang.String key)
InterlokMessage.headersContainsKey(String)
instead.Returns true if the message contains metadata against the passed key.
key
- the key to look forvoid addMetadata(java.lang.String key, java.lang.String value)
Puts the passed value
into the metadata against the passed
key
. If a value has previously been set against this
key
it will be overwritten.
key
- the keyvalue
- the valuevoid addMetadata(MetadataElement metadata)
Puts the passed MetadataElement
into the metadata. If a value
has previously been set with the same key
it will be
overwritten and a message to that effect should be logged.
metadata
- the MetadataElement
to addvoid removeMetadata(MetadataElement element)
Removes the passed MetadataElement
from the metadata if it is
present.
element
- the MetadataElement
to removejava.util.Set<MetadataElement> getMetadata()
Returns a shallow clone of this message's metadata.
Set
of all MetadataElements
svoid setMetadata(java.util.Set<MetadataElement> metadata)
This will overwrite any pre-existing keys, but will not remove existing metadata
metadata
- the metadata to addvoid clearMetadata()
Clears the current metadata.
AdaptrisMessageFactory getFactory()
java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a deep clone of this object.
java.lang.CloneNotSupportedException
- if the implementation does not support
cloningvoid addEvent(MessageEventGenerator meg, boolean wasSuccessful)
Adds an event to this AdaptrisMessage
's
MessageLifecycleEvent
.
meg
- the MessageEventGenerator
wasSuccessful
- the status of the eventMessageLifecycleEvent getMessageLifecycleEvent()
Returns this object's MessageLifecycleEvent
.
MessageLifecycleEvent
byte[] encode(AdaptrisMessageEncoder encoder) throws CoreException
Uses the passed AdaptrisMessageEncoder
to create an encoded
version of this AdaptrisMessage
. If null is passed this method
returns this.getPayload()
.
encoder
- the AdaptrisMessageEncoder
to useCoreException
- wrapping any underlying Exceptions that may occur@Deprecated default void addObjectMetadata(java.lang.String key, java.lang.Object object)
InterlokMessage.addObjectHeader(Object, Object)
instead.
Adds an Object
to this message as metadata. Object metadata is
intended to be used within a single Workflow
only and will not
be encoded or otherwise transported between Workflows.
object
- the Object
to set as metadatakey
- the key to store this object against.@Deprecated default java.util.Map getObjectMetadata()
InterlokMessage.getObjectHeaders()
instead.
Returns the Map
of Object
metadata.
Map
of Object
metadatadefault java.lang.String getPayloadForLogging()
java.lang.String getNextServiceId()
Returns the unique ID of the next Service
to apply to the
message. Optional, used by BranchingServiceCollection
and
possibly others later.
Service
to applyvoid setNextServiceId(java.lang.String uniqueId)
Sets the unique ID of the next Service
to apply to the
message.
uniqueId
- the unique ID of the next Service
to apply to
the messagejava.lang.String getMetadataValueIgnoreKeyCase(java.lang.String key)
First looks for a metadata value stored against the passed key taking account of the passed key's case. If a value is found it is returned. Next looks for a metadata value stored against the passed key ignoring. The valued stored against the first key which matches the passed key ignoring case is returned. As the underlying store is unordered, which key will match first is undefined. If no key matches the passed key ignoring case, null is returned.
E.g. where a message has the metdadata values "1" and "2" set against keys
"AAA" and "aaa" respectively, calling
getMetadataValueIgnoreKeyCase("AAA")
will return "1', calling
getMetadataValueIgnoreKeyCase("aaa")
will return "2', and
calling getMetadataValueIgnoreKeyCase("aAA")
will return
either "1' or "2".
key
- the key to look forboolean equivalentForTracking(AdaptrisMessage other)
AdaptrisMessage
's are equivalent for tracking if they
have the same unique Id, their payloads are equal, their char encodings are
equal and their metadata is equal. NB equality of metadata is based on key
only.
other
- the message to compare