Interface AdaptrisMessage
-
- All Superinterfaces:
InterlokMessage
- All Known Subinterfaces:
FileBackedMessage
,MultiPayloadAdaptrisMessage
- All Known Implementing Classes:
AdaptrisMessageImp
,DefaultAdaptrisMessageImp
,MultiPayloadAdaptrisMessageImp
public interface AdaptrisMessage extends InterlokMessage
Represents a message in the framework.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
addEvent(MessageEventGenerator meg, boolean wasSuccessful)
Adds an event to thisAdaptrisMessage
'sMessageLifecycleEvent
.void
addMetadata(MetadataElement metadata)
Puts the passedMetadataElement
into the metadata.void
addMetadata(java.lang.String key, java.lang.String value)
Puts the passedvalue
into the metadata against the passedkey
.default void
addObjectMetadata(java.lang.String key, java.lang.Object object)
Deprecated.since 3.0.6 useInterlokMessage.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 useInterlokMessage.headersContainsKey(String)
instead.byte[]
encode(AdaptrisMessageEncoder encoder)
Uses the passedAdaptrisMessageEncoder
to create an encoded version of thisAdaptrisMessage
.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'sMessageLifecycleEvent
.java.util.Set<MetadataElement>
getMetadata()
Returns a shallow clone of this message's metadata.MetadataElement
getMetadata(java.lang.String key)
Returns theMetadataElement
containing the passedkey
ornull
if thekey
does not exist.java.lang.String
getMetadataValue(java.lang.String key)
Returns theString
value associated with the passedkey
ornull
if thekey
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 nextService
to apply to the message.default java.util.Map
getObjectMetadata()
Deprecated.since 3.0.6 useInterlokMessage.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 passedMetadataElement
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 nextService
to apply to the message.void
setPayload(byte[] payload)
Sets the passedbyte[]
as this message's payload.default void
setStringPayload(java.lang.String payload)
Deprecated.you should usesetStringPayload(String, String)
and formally declare the encoding you wish to use for this string; since 2.9.3default void
setStringPayload(java.lang.String payload, java.lang.String charEncoding)
Deprecated.since 3.0.6 UseInterlokMessage.setContent(String, String)
-
Methods inherited from interface com.adaptris.interlok.types.InterlokMessage
addMessageHeader, addObjectHeader, getContent, getContentEncoding, getInputStream, getMessageHeaders, getObjectHeaders, getOutputStream, getReader, getUniqueId, getWriter, getWriter, headersContainsKey, removeMessageHeader, resolve, resolve, resolveObject, setContent, setContentEncoding, setMessageHeaders, setUniqueId, wrap
-
-
-
-
Method Detail
-
setPayload
void setPayload(byte[] payload)
Sets the passed
byte[]
as this message's payload.- Parameters:
payload
- the payload
-
getPayload
byte[] getPayload()
Returns a copy of this message's payload in its raw,
byte[]
form.- Returns:
- payload in
byte[]
form
-
getSize
long getSize()
Return the size of the payload.- Returns:
- the size of the payload.
-
setStringPayload
@Deprecated default void setStringPayload(java.lang.String payload)
Deprecated.you should usesetStringPayload(String, String)
and formally declare the encoding you wish to use for this string; since 2.9.3Sets the passed
String
as the payload. The passedString
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 usesetStringPayload(String, String)
.- Parameters:
payload
- the payload to set
-
setStringPayload
@Deprecated default void setStringPayload(java.lang.String payload, java.lang.String charEncoding)
Deprecated.since 3.0.6 UseInterlokMessage.setContent(String, String)
Sets the passed
String
with the passed character encoding as the payload. Passing null forcharEncoding
is the same as usingsetPayload(String)
.- Parameters:
payload
- the payloadcharEncoding
- the character encoding used by the payload
-
getStringPayload
@Deprecated default java.lang.String getStringPayload()
Deprecated.since 3.0.6 use {InterlokMessage.getContent()
instead.Returns a
String
representation of the payload. ThisString
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 usegetPayload
to obtain a rawbyte[]
.- Returns:
- a
String
representation of the payload
-
setCharEncoding
@Deprecated default void setCharEncoding(java.lang.String charEncoding)
Deprecated.since 3.0.6 use {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.
- Parameters:
charEncoding
- the character encoding associated with the payload.
-
getCharEncoding
@Deprecated default java.lang.String getCharEncoding()
Deprecated.since 3.0.6 use {InterlokMessage.getContentEncoding()
instead.Returns this message's character encoding, if one has been explicitly set, otherwise
null
.- Returns:
- this message's character encoding, if one has been explicitly set,
otherwise
null
-
getMetadataValue
java.lang.String getMetadataValue(java.lang.String key)
Returns the
String
value associated with the passedkey
ornull
if thekey
does not exist. NB may also returnnull
ifnull
was explicitly set as the value of the key. UsecontainsKey
to differentiate these cases.- Parameters:
key
- the key to look for- Returns:
- the value associated with the key
-
getMetadata
MetadataElement getMetadata(java.lang.String key)
Returns the
MetadataElement
containing the passedkey
ornull
if thekey
does not exist. NB may also returnnull
ifnull
was explicitly set as the value of the key. UsecontainsKey
to differentiate these cases.- Parameters:
key
- the key to look for- Returns:
- the
MetadataElement
containing the key
-
containsKey
@Deprecated default boolean containsKey(java.lang.String key)
Deprecated.since 3.0.6 useInterlokMessage.headersContainsKey(String)
instead.Returns true if the message contains metadata against the passed key.
- Parameters:
key
- the key to look for- Returns:
- true if the message contains a metadata against the passed key
-
addMetadata
void addMetadata(java.lang.String key, java.lang.String value)
Puts the passed
value
into the metadata against the passedkey
. If a value has previously been set against thiskey
it will be overwritten.- Parameters:
key
- the keyvalue
- the value
-
addMetadata
void addMetadata(MetadataElement metadata)
Puts the passed
MetadataElement
into the metadata. If a value has previously been set with the samekey
it will be overwritten and a message to that effect should be logged.- Parameters:
metadata
- theMetadataElement
to add
-
removeMetadata
void removeMetadata(MetadataElement element)
Removes the passed
MetadataElement
from the metadata if it is present.- Parameters:
element
- theMetadataElement
to remove
-
getMetadata
java.util.Set<MetadataElement> getMetadata()
Returns a shallow clone of this message's metadata.
- Returns:
- a
Set
of allMetadataElements
s
-
setMetadata
void setMetadata(java.util.Set<MetadataElement> metadata)
Adds all the passed metadata to this message's metadata.This will overwrite any pre-existing keys, but will not remove existing metadata
- Parameters:
metadata
- the metadata to add
-
clearMetadata
void clearMetadata()
Clears the current metadata.
-
getFactory
AdaptrisMessageFactory getFactory()
Return the factory that created this message.- Returns:
- the factory.
-
clone
java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a deep clone of this object.
- Returns:
- a deep clone of this object
- Throws:
java.lang.CloneNotSupportedException
- if the implementation does not support cloning
-
addEvent
void addEvent(MessageEventGenerator meg, boolean wasSuccessful)
Adds an event to this
AdaptrisMessage
'sMessageLifecycleEvent
.- Parameters:
meg
- theMessageEventGenerator
wasSuccessful
- the status of the event
-
getMessageLifecycleEvent
MessageLifecycleEvent getMessageLifecycleEvent()
Returns this object's
MessageLifecycleEvent
.- Returns:
- this object's
MessageLifecycleEvent
-
encode
byte[] encode(AdaptrisMessageEncoder encoder) throws CoreException
Uses the passed
AdaptrisMessageEncoder
to create an encoded version of thisAdaptrisMessage
. If null is passed this method returnsthis.getPayload()
.- Parameters:
encoder
- theAdaptrisMessageEncoder
to use- Returns:
- a byte[] representation of this message
- Throws:
CoreException
- wrapping any underlying Exceptions that may occur
-
addObjectMetadata
@Deprecated default void addObjectMetadata(java.lang.String key, java.lang.Object object)
Deprecated.since 3.0.6 useInterlokMessage.addObjectHeader(Object, Object)
instead.Adds an
Object
to this message as metadata. Object metadata is intended to be used within a singleWorkflow
only and will not be encoded or otherwise transported between Workflows.- Parameters:
object
- theObject
to set as metadatakey
- the key to store this object against.
-
getObjectMetadata
@Deprecated default java.util.Map getObjectMetadata()
Deprecated.since 3.0.6 useInterlokMessage.getObjectHeaders()
instead.Returns the
Map
ofObject
metadata.- Returns:
- the
Map
ofObject
metadata
-
getPayloadForLogging
default java.lang.String getPayloadForLogging()
-
getNextServiceId
java.lang.String getNextServiceId()
Returns the unique ID of the next
Service
to apply to the message. Optional, used byBranchingServiceCollection
and possibly others later.- Returns:
- the unique ID of the next
Service
to apply
-
setNextServiceId
void setNextServiceId(java.lang.String uniqueId)
Sets the unique ID of the next
Service
to apply to the message.- Parameters:
uniqueId
- the unique ID of the nextService
to apply to the message
-
getMetadataValueIgnoreKeyCase
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. 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', callinggetMetadataValueIgnoreKeyCase("aaa")
will return "2', and callinggetMetadataValueIgnoreKeyCase("aAA")
will return either "1' or "2".- Parameters:
key
- the key to look for- Returns:
- the value associated with the key or null
-
equivalentForTracking
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. NB equality of metadata is based on key only.- Parameters:
other
- the message to compare- Returns:
- true if the passed message is equivalent for tracking
-
-