public abstract class AdaptrisMessageImp extends java.lang.Object implements AdaptrisMessage, java.lang.Cloneable
Standard implementation of AdaptrisMessage
interface.
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.
Modifier | Constructor and Description |
---|---|
protected |
AdaptrisMessageImp(IdGenerator guid,
AdaptrisMessageFactory fac)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addEvent(MessageEventGenerator meg,
boolean wasSuccessful)
Adds an event to this
AdaptrisMessage 's
MessageLifecycleEvent . |
void |
addMessageHeader(java.lang.String key,
java.lang.String value) |
void |
addMetadata(MetadataElement e)
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 . |
void |
addObjectHeader(java.lang.Object key,
java.lang.Object object)
Adds an
Object to this message as metadata. |
protected static boolean |
areEqual(java.lang.String s1,
java.lang.String s2)
Deprecated.
|
void |
clearMetadata()
Clears the current metadata.
|
java.lang.Object |
clone()
Returns a deep clone of this object.
|
static void |
copyPayload(AdaptrisMessage src,
AdaptrisMessage dest)
Copy the payload from one AdaptrisMessage to another.
|
byte[] |
encode(AdaptrisMessageEncoder encoder)
Uses the passed
AdaptrisMessageEncoder to create an encoded
version of this AdaptrisMessage . |
java.lang.String |
getContentEncoding() |
AdaptrisMessageFactory |
getFactory()
Return the factory that created this message.
|
java.util.Map<java.lang.String,java.lang.String> |
getMessageHeaders() |
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. |
java.util.Map<java.lang.Object,java.lang.Object> |
getObjectHeaders() |
java.io.Reader |
getReader() |
java.lang.String |
getUniqueId() |
java.io.Writer |
getWriter() |
java.io.Writer |
getWriter(java.lang.String encoding) |
boolean |
headersContainsKey(java.lang.String key) |
void |
removeMessageHeader(java.lang.String key) |
void |
removeMetadata(MetadataElement element)
Removes the passed
MetadataElement from the metadata if it is
present. |
java.lang.String |
resolve(java.lang.String s,
boolean dotAll) |
void |
setContentEncoding(java.lang.String charEnc) |
void |
setMessageHeaders(java.util.Map<java.lang.String,java.lang.String> metadata) |
void |
setMetadata(java.util.Set<MetadataElement> set)
Adds all the passed metadata to this message's metadata.
|
void |
setNextServiceId(java.lang.String s)
Sets the unique ID of the next
Service to apply to the
message. |
void |
setUniqueId(java.lang.String s) |
java.lang.String |
toString() |
java.lang.String |
toString(boolean extended)
Overloaded
toString method which allows client to specify whether payload is
logged. |
java.lang.String |
toString(boolean includePayload,
boolean includeEvents)
Overloaded
toString method which allows client to specify whether payload is
logged. |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addObjectMetadata, containsKey, equivalentForTracking, getCharEncoding, getObjectMetadata, getPayload, getPayloadForLogging, getSize, getStringPayload, setCharEncoding, setPayload, setStringPayload, setStringPayload
getContent, getInputStream, getOutputStream, resolve, setContent, wrap
protected AdaptrisMessageImp(IdGenerator guid, AdaptrisMessageFactory fac)
Creates a new instance.
guid
- a GuidGenerator that will be used to create unique-ids.public AdaptrisMessageFactory getFactory()
AdaptrisMessage
getFactory
in interface AdaptrisMessage
public void setContentEncoding(java.lang.String charEnc)
setContentEncoding
in interface InterlokMessage
InterlokMessage.setContentEncoding(String)
public java.lang.String getContentEncoding()
getContentEncoding
in interface InterlokMessage
InterlokMessage.getContentEncoding()
public boolean headersContainsKey(java.lang.String key)
headersContainsKey
in interface InterlokMessage
InterlokMessage.headersContainsKey(String)
public void addMetadata(java.lang.String key, java.lang.String value)
AdaptrisMessage
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.
addMetadata
in interface AdaptrisMessage
key
- the keyvalue
- the valuepublic void addMessageHeader(java.lang.String key, java.lang.String value)
addMessageHeader
in interface InterlokMessage
public void addMetadata(MetadataElement e)
AdaptrisMessage
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.
addMetadata
in interface AdaptrisMessage
e
- the MetadataElement
to addAdaptrisMessage.addMetadata(MetadataElement)
public void removeMetadata(MetadataElement element)
AdaptrisMessage
Removes the passed MetadataElement
from the metadata if it is
present.
removeMetadata
in interface AdaptrisMessage
element
- the MetadataElement
to removeAdaptrisMessage.removeMetadata(MetadataElement)
public void removeMessageHeader(java.lang.String key)
removeMessageHeader
in interface InterlokMessage
InterlokMessage.removeMessageHeader(String)
public void setMetadata(java.util.Set<MetadataElement> set)
AdaptrisMessage
This will overwrite any pre-existing keys, but will not remove existing metadata
setMetadata
in interface AdaptrisMessage
set
- the metadata to addpublic void setMessageHeaders(java.util.Map<java.lang.String,java.lang.String> metadata)
setMessageHeaders
in interface InterlokMessage
public void clearMetadata()
AdaptrisMessage
Clears the current metadata.
clearMetadata
in interface AdaptrisMessage
AdaptrisMessage.clearMetadata()
public java.lang.String getMetadataValue(java.lang.String key)
AdaptrisMessage
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.
getMetadataValue
in interface AdaptrisMessage
key
- the key to look forAdaptrisMessage.getMetadataValue(String)
public MetadataElement getMetadata(java.lang.String key)
AdaptrisMessage
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.
getMetadata
in interface AdaptrisMessage
key
- the key to look forMetadataElement
containing the keyAdaptrisMessage.getMetadata(String)
public java.util.Map<java.lang.String,java.lang.String> getMessageHeaders()
getMessageHeaders
in interface InterlokMessage
public java.util.Set<MetadataElement> getMetadata()
AdaptrisMessage
Returns a shallow clone of this message's metadata.
getMetadata
in interface AdaptrisMessage
Set
of all MetadataElements
spublic java.lang.String getUniqueId()
getUniqueId
in interface InterlokMessage
public void setUniqueId(java.lang.String s)
setUniqueId
in interface InterlokMessage
public java.io.Reader getReader() throws java.io.IOException
getReader
in interface InterlokMessage
java.io.IOException
public java.io.Writer getWriter() throws java.io.IOException
getWriter
in interface InterlokMessage
java.io.IOException
public java.io.Writer getWriter(java.lang.String encoding) throws java.io.IOException
getWriter
in interface InterlokMessage
java.io.IOException
public void addEvent(MessageEventGenerator meg, boolean wasSuccessful)
AdaptrisMessage
Adds an event to this AdaptrisMessage
's
MessageLifecycleEvent
.
addEvent
in interface AdaptrisMessage
meg
- the MessageEventGenerator
wasSuccessful
- the status of the eventpublic MessageLifecycleEvent getMessageLifecycleEvent()
AdaptrisMessage
Returns this object's MessageLifecycleEvent
.
getMessageLifecycleEvent
in interface AdaptrisMessage
MessageLifecycleEvent
AdaptrisMessage.getMessageLifecycleEvent()
public byte[] encode(AdaptrisMessageEncoder encoder) throws CoreException
AdaptrisMessage
Uses the passed AdaptrisMessageEncoder
to create an encoded
version of this AdaptrisMessage
. If null is passed this method
returns this.getPayload()
.
encode
in interface AdaptrisMessage
encoder
- the AdaptrisMessageEncoder
to useCoreException
- wrapping any underlying Exceptions that may occurAdaptrisMessage.encode(AdaptrisMessageEncoder)
public void addObjectHeader(java.lang.Object key, java.lang.Object object)
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.
addObjectHeader
in interface InterlokMessage
object
- the Object
to set as metadatakey
- the key to store this object against.public java.util.Map<java.lang.Object,java.lang.Object> getObjectHeaders()
getObjectHeaders
in interface InterlokMessage
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public java.lang.String toString(boolean includePayload, boolean includeEvents)
AdaptrisMessage
Overloaded toString
method which allows client to specify whether payload is
logged. (NB by default standard toString
does log the payload).
toString
in interface AdaptrisMessage
includePayload
- true if payload should be included in returnincludeEvents
- true if the events should be included.public java.lang.String toString(boolean extended)
AdaptrisMessage
Overloaded toString
method which allows client to specify whether payload is
logged. (NB by default standard toString
does not log the payload).
toString
in interface AdaptrisMessage
extended
- true if payload should be included in returnAdaptrisMessage.toString(boolean)
public java.lang.String getNextServiceId()
AdaptrisMessage
Returns the unique ID of the next Service
to apply to the
message. Optional, used by BranchingServiceCollection
and
possibly others later.
getNextServiceId
in interface AdaptrisMessage
Service
to applyAdaptrisMessage.getNextServiceId()
public void setNextServiceId(java.lang.String s)
AdaptrisMessage
Sets the unique ID of the next Service
to apply to the
message.
setNextServiceId
in interface AdaptrisMessage
s
- the unique ID of the next Service
to apply to
the messagepublic java.lang.String resolve(java.lang.String s, boolean dotAll)
resolve
in interface InterlokMessage
public java.lang.String getMetadataValueIgnoreKeyCase(java.lang.String key)
AdaptrisMessage
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".
getMetadataValueIgnoreKeyCase
in interface AdaptrisMessage
key
- the key to look for#getMetadataValueIgnoreKeyCase(java.lang.String)
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
AdaptrisMessage
Returns a deep clone of this object.
clone
in interface AdaptrisMessage
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if the implementation does not support
cloningObject.clone()
public static void copyPayload(AdaptrisMessage src, AdaptrisMessage dest) throws java.io.IOException
src
- the source adaptris messagedest
- the destination adaptris messagejava.io.IOException
- on exception@Deprecated protected static boolean areEqual(java.lang.String s1, java.lang.String s2)