Class AdaptrisMessageImp
- java.lang.Object
- 
- com.adaptris.core.AdaptrisMessageImp
 
- 
- All Implemented Interfaces:
- AdaptrisMessage,- InterlokMessage,- java.lang.Cloneable
 - Direct Known Subclasses:
- DefaultAdaptrisMessageImp,- MultiPayloadAdaptrisMessageImp
 
 public abstract class AdaptrisMessageImp extends java.lang.Object implements AdaptrisMessage, java.lang.Cloneable Standard implementation of AdaptrisMessageinterface.When referring to metadata items by key you can use a form of indirection by specifying a prefix to your key ("$$"). 
 Using this prefix on any metadata key will not perform an action (retrieve, add etc) to that metadata item but instead will look up the value of that metadata key and use the value as the metadata item key to be performed on.
 Example:
 Calling addMetadata("myKey", "myValue");
 Will create a new metadata item with the key "myKey" and the value "myValue".
 However calling addMetadata("$$myKey", "myValue") will lookup the value of the metadata key named "myKey" and use that value as the key for the addMetadata() method.
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedAdaptrisMessageImp(IdGenerator guid, AdaptrisMessageFactory fac)Creates a new instance.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddEvent(MessageEventGenerator meg, boolean wasSuccessful)Adds an event to thisAdaptrisMessage'sMessageLifecycleEvent.voidaddMessageHeader(java.lang.String key, java.lang.String value)voidaddMetadata(MetadataElement e)Puts the passedMetadataElementinto the metadata.voidaddMetadata(java.lang.String key, java.lang.String value)Puts the passedvalueinto the metadata against the passedkey.voidaddObjectHeader(java.lang.Object key, java.lang.Object object)Adds anObjectto this message as metadata.voidclearMetadata()Clears the current metadata.java.lang.Objectclone()Returns a deep clone of this object.static voidcopyPayload(AdaptrisMessage src, AdaptrisMessage dest)Deprecated.since 3.11.0 use MessageHelper#copyPayload(AdaptrisMessage, AdaptrisMessage) instead.byte[]encode(AdaptrisMessageEncoder encoder)Uses the passedAdaptrisMessageEncoderto create an encoded version of thisAdaptrisMessage.java.lang.StringgetContentEncoding()AdaptrisMessageFactorygetFactory()Return the factory that created this message.java.util.Map<java.lang.String,java.lang.String>getMessageHeaders()MessageLifecycleEventgetMessageLifecycleEvent()Returns this object'sMessageLifecycleEvent.java.util.Set<MetadataElement>getMetadata()Returns a shallow clone of this message's metadata.MetadataElementgetMetadata(java.lang.String key)Returns theMetadataElementcontaining the passedkeyornullif thekeydoes not exist.java.lang.StringgetMetadataValue(java.lang.String key)Returns theStringvalue associated with the passedkeyornullif thekeydoes not exist.java.lang.StringgetMetadataValueIgnoreKeyCase(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.StringgetNextServiceId()Returns the unique ID of the nextServiceto apply to the message.java.util.Map<java.lang.Object,java.lang.Object>getObjectHeaders()java.io.ReadergetReader()java.lang.StringgetUniqueId()java.io.WritergetWriter()java.io.WritergetWriter(java.lang.String encoding)booleanheadersContainsKey(java.lang.String key)voidremoveMessageHeader(java.lang.String key)voidremoveMetadata(MetadataElement element)Removes the passedMetadataElementfrom the metadata if it is present.java.lang.Stringresolve(java.lang.String s, boolean dotAll)java.lang.ObjectresolveObject(java.lang.String s)Retrieve an object from headers/metadata using an expression: %messageObject{some_key}voidsetContentEncoding(java.lang.String charEnc)voidsetMessageHeaders(java.util.Map<java.lang.String,java.lang.String> metadata)voidsetMetadata(java.util.Set<MetadataElement> set)Adds all the passed metadata to this message's metadata.voidsetNextServiceId(java.lang.String s)Sets the unique ID of the nextServiceto apply to the message.voidsetUniqueId(java.lang.String s)java.lang.StringtoString()- 
Methods inherited from class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface com.adaptris.core.AdaptrisMessageaddObjectMetadata, containsKey, equivalentForTracking, getCharEncoding, getObjectMetadata, getPayload, getPayloadForLogging, getSize, getStringPayload, setCharEncoding, setPayload, setStringPayload, setStringPayload
 - 
Methods inherited from interface com.adaptris.interlok.types.InterlokMessagegetContent, getInputStream, getOutputStream, resolve, setContent, wrap
 
- 
 
- 
- 
- 
Constructor Detail- 
AdaptrisMessageImpprotected AdaptrisMessageImp(IdGenerator guid, AdaptrisMessageFactory fac) Creates a new instance. - Parameters:
- guid- a GuidGenerator that will be used to create unique-ids.
 
 
- 
 - 
Method Detail- 
getFactorypublic AdaptrisMessageFactory getFactory() Description copied from interface:AdaptrisMessageReturn the factory that created this message.- Specified by:
- getFactoryin interface- AdaptrisMessage
- Returns:
- the factory.
 
 - 
setContentEncodingpublic void setContentEncoding(java.lang.String charEnc) - Specified by:
- setContentEncodingin interface- InterlokMessage
- See Also:
- InterlokMessage.setContentEncoding(String)
 
 - 
getContentEncodingpublic java.lang.String getContentEncoding() - Specified by:
- getContentEncodingin interface- InterlokMessage
- See Also:
- InterlokMessage.getContentEncoding()
 
 - 
headersContainsKeypublic boolean headersContainsKey(java.lang.String key) - Specified by:
- headersContainsKeyin interface- InterlokMessage
- See Also:
- InterlokMessage.headersContainsKey(String)
 
 - 
addMetadatapublic void addMetadata(java.lang.String key, java.lang.String value)Description copied from interface:AdaptrisMessagePuts the passed valueinto the metadata against the passedkey. If a value has previously been set against thiskeyit will be overwritten.- Specified by:
- addMetadatain interface- AdaptrisMessage
- Parameters:
- key- the key
- value- the value
 
 - 
addMessageHeaderpublic void addMessageHeader(java.lang.String key, java.lang.String value)- Specified by:
- addMessageHeaderin interface- InterlokMessage
 
 - 
addMetadatapublic void addMetadata(MetadataElement e) Description copied from interface:AdaptrisMessagePuts 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.- Specified by:
- addMetadatain interface- AdaptrisMessage
- Parameters:
- e- the- MetadataElementto add
- See Also:
- AdaptrisMessage.addMetadata(MetadataElement)
 
 - 
removeMetadatapublic void removeMetadata(MetadataElement element) Description copied from interface:AdaptrisMessageRemoves the passed MetadataElementfrom the metadata if it is present.- Specified by:
- removeMetadatain interface- AdaptrisMessage
- Parameters:
- element- the- MetadataElementto remove
- See Also:
- AdaptrisMessage.removeMetadata(MetadataElement)
 
 - 
removeMessageHeaderpublic void removeMessageHeader(java.lang.String key) - Specified by:
- removeMessageHeaderin interface- InterlokMessage
- See Also:
- InterlokMessage.removeMessageHeader(String)
 
 - 
setMetadatapublic void setMetadata(java.util.Set<MetadataElement> set) Description copied from interface:AdaptrisMessageAdds all the passed metadata to this message's metadata.This will overwrite any pre-existing keys, but will not remove existing metadata - Specified by:
- setMetadatain interface- AdaptrisMessage
- Parameters:
- set- the metadata to add
 
 - 
setMessageHeaderspublic void setMessageHeaders(java.util.Map<java.lang.String,java.lang.String> metadata) - Specified by:
- setMessageHeadersin interface- InterlokMessage
 
 - 
clearMetadatapublic void clearMetadata() Description copied from interface:AdaptrisMessageClears the current metadata. - Specified by:
- clearMetadatain interface- AdaptrisMessage
- See Also:
- AdaptrisMessage.clearMetadata()
 
 - 
getMetadataValuepublic java.lang.String getMetadataValue(java.lang.String key) Description copied from interface:AdaptrisMessageReturns 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.- Specified by:
- getMetadataValuein interface- AdaptrisMessage
- Parameters:
- key- the key to look for
- Returns:
- the value associated with the key
- See Also:
- AdaptrisMessage.getMetadataValue(String)
 
 - 
getMetadatapublic MetadataElement getMetadata(java.lang.String key) Description copied from interface:AdaptrisMessageReturns the MetadataElementcontaining the passedkeyornullif thekeydoes not exist. NB may also returnnullifnullwas explicitly set as the value of the key. UsecontainsKeyto differentiate these cases.- Specified by:
- getMetadatain interface- AdaptrisMessage
- Parameters:
- key- the key to look for
- Returns:
- the MetadataElementcontaining the key
- See Also:
- AdaptrisMessage.getMetadata(String)
 
 - 
getMessageHeaderspublic java.util.Map<java.lang.String,java.lang.String> getMessageHeaders() - Specified by:
- getMessageHeadersin interface- InterlokMessage
 
 - 
getMetadatapublic java.util.Set<MetadataElement> getMetadata() Description copied from interface:AdaptrisMessageReturns a shallow clone of this message's metadata. - Specified by:
- getMetadatain interface- AdaptrisMessage
- Returns:
- a Setof allMetadataElementss
 
 - 
getUniqueIdpublic java.lang.String getUniqueId() - Specified by:
- getUniqueIdin interface- InterlokMessage
 
 - 
setUniqueIdpublic void setUniqueId(java.lang.String s) - Specified by:
- setUniqueIdin interface- InterlokMessage
 
 - 
getReaderpublic java.io.Reader getReader() throws java.io.IOException- Specified by:
- getReaderin interface- InterlokMessage
- Throws:
- java.io.IOException
 
 - 
getWriterpublic java.io.Writer getWriter() throws java.io.IOException- Specified by:
- getWriterin interface- InterlokMessage
- Throws:
- java.io.IOException
 
 - 
getWriterpublic java.io.Writer getWriter(java.lang.String encoding) throws java.io.IOException- Specified by:
- getWriterin interface- InterlokMessage
- Throws:
- java.io.IOException
 
 - 
addEventpublic void addEvent(MessageEventGenerator meg, boolean wasSuccessful) Description copied from interface:AdaptrisMessageAdds an event to this AdaptrisMessage'sMessageLifecycleEvent.- Specified by:
- addEventin interface- AdaptrisMessage
- Parameters:
- meg- the- MessageEventGenerator
- wasSuccessful- the status of the event
 
 - 
getMessageLifecycleEventpublic MessageLifecycleEvent getMessageLifecycleEvent() Description copied from interface:AdaptrisMessageReturns this object's MessageLifecycleEvent.- Specified by:
- getMessageLifecycleEventin interface- AdaptrisMessage
- Returns:
- this object's MessageLifecycleEvent
- See Also:
- AdaptrisMessage.getMessageLifecycleEvent()
 
 - 
encodepublic byte[] encode(AdaptrisMessageEncoder encoder) throws CoreException Description copied from interface:AdaptrisMessageUses the passed AdaptrisMessageEncoderto create an encoded version of thisAdaptrisMessage. If null is passed this method returnsthis.getPayload().- Specified by:
- encodein interface- AdaptrisMessage
- Parameters:
- encoder- the- AdaptrisMessageEncoderto use
- Returns:
- a byte[] representation of this message
- Throws:
- CoreException- wrapping any underlying Exceptions that may occur
- See Also:
- AdaptrisMessage.encode(AdaptrisMessageEncoder)
 
 - 
addObjectHeaderpublic void addObjectHeader(java.lang.Object key, java.lang.Object object)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.- Specified by:
- addObjectHeaderin interface- InterlokMessage
- Parameters:
- object- the- Objectto set as metadata
- key- the key to store this object against.
 
 - 
getObjectHeaderspublic java.util.Map<java.lang.Object,java.lang.Object> getObjectHeaders() - Specified by:
- getObjectHeadersin interface- InterlokMessage
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
- See Also:
- Object.toString()
 
 - 
getNextServiceIdpublic java.lang.String getNextServiceId() Description copied from interface:AdaptrisMessageReturns the unique ID of the next Serviceto apply to the message. Optional, used byBranchingServiceCollectionand possibly others later.- Specified by:
- getNextServiceIdin interface- AdaptrisMessage
- Returns:
- the unique ID of the next Serviceto apply
- See Also:
- AdaptrisMessage.getNextServiceId()
 
 - 
setNextServiceIdpublic void setNextServiceId(java.lang.String s) Description copied from interface:AdaptrisMessageSets the unique ID of the next Serviceto apply to the message.- Specified by:
- setNextServiceIdin interface- AdaptrisMessage
- Parameters:
- s- the unique ID of the next- Serviceto apply to the message
 
 - 
resolvepublic java.lang.String resolve(java.lang.String s, boolean dotAll)- Specified by:
- resolvein interface- InterlokMessage
 
 - 
resolveObjectpublic java.lang.Object resolveObject(java.lang.String s) Retrieve an object from headers/metadata using an expression: %messageObject{some_key}- Specified by:
- resolveObjectin interface- InterlokMessage
- Parameters:
- s- The expression to use to resolve the object.
- Returns:
- The header/metadata object, or null.
 
 - 
getMetadataValueIgnoreKeyCasepublic java.lang.String getMetadataValueIgnoreKeyCase(java.lang.String key) Description copied from interface:AdaptrisMessageFirst 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".- Specified by:
- getMetadataValueIgnoreKeyCasein interface- AdaptrisMessage
- Parameters:
- key- the key to look for
- Returns:
- the value associated with the key or null
- See Also:
- #getMetadataValueIgnoreKeyCase(java.lang.String)
 
 - 
clonepublic java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionDescription copied from interface:AdaptrisMessageReturns a deep clone of this object. - Specified by:
- clonein interface- AdaptrisMessage
- Overrides:
- clonein class- java.lang.Object
- Returns:
- a deep clone of this object
- Throws:
- java.lang.CloneNotSupportedException- if the implementation does not support cloning
- See Also:
- Object.clone()
 
 - 
copyPayload@Deprecated public static void copyPayload(AdaptrisMessage src, AdaptrisMessage dest) throws java.io.IOException Deprecated.since 3.11.0 use MessageHelper#copyPayload(AdaptrisMessage, AdaptrisMessage) instead.Copy the payload from one AdaptrisMessage to another.- Throws:
- java.io.IOException
 
 
- 
 
-