Interface AdaptrisMessage
- All Superinterfaces:
InterlokMessage
- All Known Subinterfaces:
FileBackedMessage,MultiPayloadAdaptrisMessage
- All Known Implementing Classes:
AdaptrisMessageImp,DefaultAdaptrisMessageImp,MultiPayloadAdaptrisMessageImp
Represents a message in the framework.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddEvent(MessageEventGenerator meg, boolean wasSuccessful) Adds an event to thisAdaptrisMessage'sMessageLifecycleEvent.voidaddMetadata(MetadataElement metadata) Puts the passedMetadataElementinto the metadata.voidaddMetadata(String key, String value) Puts the passedvalueinto the metadata against the passedkey.default voidaddMetadata(Collection<MetadataElement> metadata) Adds all the passed metadata to this message's metadata.default voidaddObjectMetadata(String key, Object object) Deprecated.default voidClears the current metadata.clone()Returns a deep clone of this object.default booleancontainsKey(String key) Deprecated.since 3.0.6 useInterlokMessage.headersContainsKey(String)instead.byte[]encode(AdaptrisMessageEncoder encoder) Uses the passedAdaptrisMessageEncoderto create an encoded version of thisAdaptrisMessage.booleanAdaptrisMessage'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 StringDeprecated.since 3.0.6 use {InterlokMessage.getContentEncoding()instead.Return the factory that created this message.Returns this object'sMessageLifecycleEvent.Returns a shallow clone of this message's metadata.getMetadata(String key) Returns theMetadataElementcontaining the passedkeyornullif thekeydoes not exist.getMetadataValue(String key) Returns theStringvalue associated with the passedkeyornullif thekeydoes not exist.First looks for a metadata value stored against the passed key taking account of the passed key's case.Returns the unique ID of the nextServiceto apply to the message.default MapDeprecated.since 3.0.6 useInterlokMessage.getObjectHeaders()instead.byte[]Returns a copy of this message's payload in its raw,byte[]form.default StringlonggetSize()Return the size of the payload.default StringDeprecated.since 3.0.6 use {InterlokMessage.getContent()instead.voidremoveMetadata(MetadataElement element) Removes the passedMetadataElementfrom the metadata if it is present.default voidreplaceAllMetadata(Collection<MetadataElement> metadata) Replace all the metadata associated with the messagedefault voidsetCharEncoding(String charEncoding) Deprecated.since 3.0.6 use {InterlokMessage.setContentEncoding(String)instead.default voidsetMetadata(Set<MetadataElement> metadata) Deprecated.since 4.5.0 because it is poorly named since it is only additive; useaddMetadata(Collection)instead.voidsetNextServiceId(String uniqueId) Sets the unique ID of the nextServiceto apply to the message.voidsetPayload(byte[] payload) Sets the passedbyte[]as this message's payload.default voidsetStringPayload(String payload) Deprecated.you should usesetStringPayload(String, String)and formally declare the encoding you wish to use for this string; since 2.9.3default voidsetStringPayload(String payload, String charEncoding) Deprecated.since 3.0.6 UseInterlokMessage.setContent(String, String)Methods inherited from interface com.adaptris.interlok.types.InterlokMessage
addMessageHeader, addMessageHeaders, addObjectHeader, clearMessageHeaders, getContent, getContentEncoding, getInputStream, getMessageHeaders, getObjectHeaders, getOutputStream, getReader, getUniqueId, getWriter, getWriter, headersContainsKey, removeMessageHeader, replaceAllMessageHeaders, resolve, resolve, resolveObject, setContent, setContentEncoding, setMessageHeaders, setUniqueId, wrap
-
Method Details
-
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.you should usesetStringPayload(String, String)and formally declare the encoding you wish to use for this string; since 2.9.3Sets the passed
Stringas the payload. The passedStringis 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 @Removal(version="5.1.0") default void setStringPayload(String payload, String charEncoding) Deprecated.since 3.0.6 UseInterlokMessage.setContent(String, String)Sets the passed
Stringwith the passed character encoding as the payload. Passing null forcharEncodingis the same as usingsetPayload(String).- Parameters:
payload- the payloadcharEncoding- the character encoding used by the payload
-
getStringPayload
Deprecated.since 3.0.6 use {InterlokMessage.getContent()instead.Returns a
Stringrepresentation of the payload. ThisStringwill 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 usegetPayloadto obtain a rawbyte[].- Returns:
- a
Stringrepresentation of the payload
-
setCharEncoding
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.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
Returns the
Stringvalue associated with the passedkeyornullif thekeydoes not exist. NB may also returnnullifnullwas explicitly set as the value of the key. UsecontainsKeyto differentiate these cases.- Parameters:
key- the key to look for- Returns:
- the value associated with the key
-
getMetadata
Returns the
MetadataElementcontaining the passedkeyornullif thekeydoes not exist. NB may also returnnullifnullwas explicitly set as the value of the key. UsecontainsKeyto differentiate these cases.- Parameters:
key- the key to look for- Returns:
- the
MetadataElementcontaining the key
-
containsKey
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
Puts the passed
valueinto the metadata against the passedkey. If a value has previously been set against thiskeyit will be overwritten.- Parameters:
key- the keyvalue- the value
-
addMetadata
Puts the passed
MetadataElementinto the metadata. If a value has previously been set with the samekeyit will be overwritten and a message to that effect should be logged.- Parameters:
metadata- theMetadataElementto add
-
removeMetadata
Removes the passed
MetadataElementfrom the metadata if it is present.- Parameters:
element- theMetadataElementto remove
-
getMetadata
Set<MetadataElement> getMetadata()Returns a shallow clone of this message's metadata.
- Returns:
- a
Setof allMetadataElementss
-
setMetadata
Deprecated.since 4.5.0 because it is poorly named since it is only additive; useaddMetadata(Collection)instead.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
-
addMetadata
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- Implementation Note:
- The default implementation simply uses
addMetadata(MetadataElement)iterating over the collection; if the collection contains duplicates then behaviour is delegated to the underlying implementation.
-
replaceAllMetadata
Replace all the metadata associated with the messageThis is largely a semantic replacement for
setMessageHeaders(Map)which defaults the correct behaviour.- Parameters:
metadata- the metadata that replaces the existing metadata.- Implementation Note:
- The default implementation simply uses
addMetadata(MetadataElement)after callingclearMetadata().
-
clearMetadata
default void clearMetadata()Clears the current metadata.
- Implementation Note:
- The default implementation simply uses
#clearMessageHeaders()}
-
getFactory
AdaptrisMessageFactory getFactory()Return the factory that created this message.- Returns:
- the factory.
-
clone
Returns a deep clone of this object.
- Returns:
- a deep clone of this object
- Throws:
CloneNotSupportedException- if the implementation does not support cloning
-
addEvent
Adds an event to this
AdaptrisMessage'sMessageLifecycleEvent.- Parameters:
meg- theMessageEventGeneratorwasSuccessful- the status of the event
-
getMessageLifecycleEvent
MessageLifecycleEvent getMessageLifecycleEvent()Returns this object's
MessageLifecycleEvent.- Returns:
- this object's
MessageLifecycleEvent
-
encode
Uses the passed
AdaptrisMessageEncoderto create an encoded version of thisAdaptrisMessage. If null is passed this method returnsthis.getPayload().- Parameters:
encoder- theAdaptrisMessageEncoderto use- Returns:
- a byte[] representation of this message
- Throws:
CoreException- wrapping any underlying Exceptions that may occur
-
addObjectMetadata
Deprecated.since 3.0.6 useInterlokMessage.addObjectHeader(Object, Object)instead.Adds an
Objectto this message as metadata. Object metadata is intended to be used within a singleWorkflowonly and will not be encoded or otherwise transported between Workflows.- Parameters:
object- theObjectto set as metadatakey- the key to store this object against.
-
getObjectMetadata
Deprecated.since 3.0.6 useInterlokMessage.getObjectHeaders()instead.Returns the
MapofObjectmetadata.- Returns:
- the
MapofObjectmetadata
-
getPayloadForLogging
-
getNextServiceId
String getNextServiceId()Returns the unique ID of the next
Serviceto apply to the message. Optional, used byBranchingServiceCollectionand possibly others later.- Returns:
- the unique ID of the next
Serviceto apply
-
setNextServiceId
Sets the unique ID of the next
Serviceto apply to the message.- Parameters:
uniqueId- the unique ID of the nextServiceto apply to the message
-
getMetadataValueIgnoreKeyCase
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
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
-
InterlokMessage.addObjectHeader(Object, Object)instead.