Package com.adaptris.core
Class MimeEncoder
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageEncoderImp<T,S>
-
- com.adaptris.core.MimeEncoderImpl<java.io.OutputStream,java.io.InputStream>
-
- com.adaptris.core.MimeEncoder
-
- All Implemented Interfaces:
AdaptrisMessageEncoder<java.io.OutputStream,java.io.InputStream>
,AdaptrisMessageTranslator
public class MimeEncoder extends MimeEncoderImpl<java.io.OutputStream,java.io.InputStream>
Implementation of
AdaptrisMessageEncoder
that storesAdaptrisMessage
payload and metadata as a mime-encoded multipart message.The metadata is treated as a though it were a set of Properties, therefore using = as part of either the metadata key or data makes the behaviour undefined.
By default the data is not encoded, however this behaviour can be overriden through use of the
setMetadataEncoding()
andsetPayloadEncoding()
methods.In the adapter configuration file this class is aliased as mime-encoder which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.MimeEncoderImpl
EXCEPTION_CONTENT_ID, METADATA_CONTENT_ID, PAYLOAD_CONTENT_ID
-
Fields inherited from class com.adaptris.core.AdaptrisMessageEncoderImp
log
-
-
Constructor Summary
Constructors Constructor Description MimeEncoder()
MimeEncoder(java.lang.Boolean retainUniqueId, java.lang.String metadataEncoding, java.lang.String payloadEncoding)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AdaptrisMessage
decode(byte[] bytes)
Convenience method that is available so that existing underlying implementations are not broken due to the AdaptrisMessageEncoder interface change.byte[]
encode(AdaptrisMessage msg)
Convenience method that is available so that existing underlying implementations are not broken due to the AdaptrisMessageEncoder interface change.AdaptrisMessage
readMessage(java.io.InputStream source)
Decode the supplied Object into anAdaptrisMessage
object.void
writeMessage(AdaptrisMessage msg, java.io.OutputStream target)
Encode theAdaptrisMessage
object and write it to the supplied target-
Methods inherited from class com.adaptris.core.MimeEncoderImpl
addPartsToMessage, asMimePart, getMetadata, getMetadataEncoding, getMetadataSet, getPayloadEncoding, getRetainUniqueId, payloadAsMimePart, retainUniqueId, setMetadataEncoding, setPayloadEncoding, setRetainUniqueId
-
Methods inherited from class com.adaptris.core.AdaptrisMessageEncoderImp
currentMessageFactory, registerMessageFactory
-
-
-
-
Method Detail
-
writeMessage
public void writeMessage(AdaptrisMessage msg, java.io.OutputStream target) throws CoreException
Description copied from interface:AdaptrisMessageEncoder
Encode theAdaptrisMessage
object and write it to the supplied target- Parameters:
msg
- theAdaptrisMessage
to be encodedtarget
- the destination to write to.- Throws:
CoreException
- wrapping any underlying Exceptions that may occur
-
readMessage
public AdaptrisMessage readMessage(java.io.InputStream source) throws CoreException
Description copied from interface:AdaptrisMessageEncoder
Decode the supplied Object into anAdaptrisMessage
object.- Parameters:
source
- the object to be decoded.- Returns:
- an
AdaptrisMessage
created from the object. - Throws:
CoreException
- wrapping any underlying Exceptions that may occur
-
encode
public byte[] encode(AdaptrisMessage msg) throws CoreException
Convenience method that is available so that existing underlying implementations are not broken due to the AdaptrisMessageEncoder interface change.- Parameters:
msg
- the message to encode as a byte array.- Throws:
CoreException
-
decode
public AdaptrisMessage decode(byte[] bytes) throws CoreException
Convenience method that is available so that existing underlying implementations are not broken due to the AdaptrisMessageEncoder interface change.- Parameters:
bytes
- the bytes to decode.- Returns:
- the AdaptrisMessage.
- Throws:
CoreException
- wrapping any underyling exception.
-
-