public abstract class AdaptrisMessageFactory
extends java.lang.Object
A static
factory which returns implementations of
AdaptrisMessage
.
Constructor and Description |
---|
AdaptrisMessageFactory() |
Modifier and Type | Method and Description |
---|---|
static AdaptrisMessageFactory |
defaultIfNull(AdaptrisMessageFactory f)
Convenience method for null protection.
|
abstract java.lang.String |
getDefaultCharEncoding()
Return the default character encoding for the message.
|
static AdaptrisMessageFactory |
getDefaultInstance()
Get the default implementationion of AdaptrisMessageFactory.
|
IdGenerator |
getUniqueIdGenerator() |
abstract AdaptrisMessage |
newMessage()
Returns a new
AdaptrisMessage . |
abstract AdaptrisMessage |
newMessage(AdaptrisMessage source,
java.util.Collection<java.lang.String> metadataKeysToPreserve)
Returns a new
AdaptrisMessage with an empty payload but with
selected metadata from the source. |
abstract AdaptrisMessage |
newMessage(byte[] payload)
Returns a new
AdaptrisMessage with the specified payload and
metadata. |
abstract AdaptrisMessage |
newMessage(byte[] payload,
java.util.Set metadata)
Returns a new
AdaptrisMessage with the specified payload and metadata. |
abstract AdaptrisMessage |
newMessage(java.lang.String payload)
Returns a new
AdaptrisMessage with the specified payload and
metadata. |
abstract AdaptrisMessage |
newMessage(java.lang.String payload,
java.util.Set metadata)
Returns a new
AdaptrisMessage with the specified payload and
metadata. |
abstract AdaptrisMessage |
newMessage(java.lang.String payload,
java.lang.String charEncoding)
Returns a new
AdaptrisMessage with the specified payload and
metadata. |
abstract AdaptrisMessage |
newMessage(java.lang.String payload,
java.lang.String charEncoding,
java.util.Set metadata)
Returns a new
AdaptrisMessage with the specified payload and
metadata. |
abstract void |
setDefaultCharEncoding(java.lang.String s)
Set the default character encoding to be applied to the message upon
creation.
|
void |
setUniqueIdGenerator(IdGenerator s)
Set the unique id generator used for messages.
|
protected IdGenerator |
uniqueIdGenerator() |
public static AdaptrisMessageFactory getDefaultInstance()
Generally speaking, the appropriate message factory should be already be configured explicitly and available to be used. This method is simply here for those instances where no AdaptrisMessageFactory is available.
AdaptrisMessageWorker.getMessageFactory()
,
AdaptrisMessageTranslator.currentMessageFactory()
,
DefaultMessageFactory
public static AdaptrisMessageFactory defaultIfNull(AdaptrisMessageFactory f)
f
- the configured message factory.public abstract AdaptrisMessage newMessage(byte[] payload, java.util.Set metadata)
Returns a new AdaptrisMessage
with the specified payload and metadata.
payload
- the byte[]
payloadmetadata
- a Set
of MetadataElement
sAdaptrisMessage
public abstract AdaptrisMessage newMessage(byte[] payload)
Returns a new AdaptrisMessage
with the specified payload and
metadata.
payload
- the byte[]
payloadAdaptrisMessage
public abstract AdaptrisMessage newMessage(java.lang.String payload, java.util.Set metadata)
Returns a new AdaptrisMessage
with the specified payload and
metadata. Uses default platform character encoding.
payload
- the String
payloadmetadata
- a Set
of MetadataElement
sAdaptrisMessage
public abstract AdaptrisMessage newMessage(java.lang.String payload)
Returns a new AdaptrisMessage
with the specified payload and
metadata. Uses default platform character encoding.
payload
- the String
payloadAdaptrisMessage
public abstract AdaptrisMessage newMessage(java.lang.String payload, java.lang.String charEncoding, java.util.Set metadata) throws java.io.UnsupportedEncodingException
Returns a new AdaptrisMessage
with the specified payload and
metadata. Uses default platform character encoding.
payload
- the String
payloadmetadata
- a Set
of MetadataElement
scharEncoding
- the String
's character encodingAdaptrisMessage
java.io.UnsupportedEncodingException
- if the passed character encoding is
not supportedpublic abstract AdaptrisMessage newMessage(java.lang.String payload, java.lang.String charEncoding) throws java.io.UnsupportedEncodingException
Returns a new AdaptrisMessage
with the specified payload and
metadata. Uses default platform character encoding.
payload
- the String
payloadcharEncoding
- the String
's character encodingAdaptrisMessage
java.io.UnsupportedEncodingException
- if the passed character encoding is
not supportedpublic abstract AdaptrisMessage newMessage(AdaptrisMessage source, java.util.Collection<java.lang.String> metadataKeysToPreserve) throws java.lang.CloneNotSupportedException
AdaptrisMessage
with an empty payload but with
selected metadata from the source.
The new AdaptrisMessage will have the same message id and MessageLifecycleEvent will be cloned from the original. Object metadata will also be preserved.
source
- the original AdaptrisMessagemetadataKeysToPreserve
- a list of keys to transfer to the new Message; if null, then all keys.AdaptrisMessage
java.lang.CloneNotSupportedException
- if the MleMarkers could not be cloned.public abstract java.lang.String getDefaultCharEncoding()
public abstract void setDefaultCharEncoding(java.lang.String s)
If not explicitly configured, then the platform default character encoding should be used.
s
- the defaultCharEncoding to setAdaptrisMessage.setCharEncoding(String)
public abstract AdaptrisMessage newMessage()
Returns a new AdaptrisMessage
. Payload and metadata are null.
AdaptrisMessage
with the specified payload and
metadatapublic IdGenerator getUniqueIdGenerator()
public void setUniqueIdGenerator(IdGenerator s)
In some situations you may not want to use the default GuidGenerator
instance when assigning unique ids to messages.
This allows you to change the IdGenerator
used both for message ids unique ids associated with
MessageLifecycleEvent
.
s
- the uniqueIdGenerator to setprotected IdGenerator uniqueIdGenerator()