Class 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 stores AdaptrisMessage 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() and setPayloadEncoding() 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.

    • Constructor Detail

      • MimeEncoder

        public MimeEncoder()
      • MimeEncoder

        public MimeEncoder​(java.lang.Boolean retainUniqueId,
                           java.lang.String metadataEncoding,
                           java.lang.String payloadEncoding)
    • Method Detail

      • writeMessage

        public void writeMessage​(AdaptrisMessage msg,
                                 java.io.OutputStream target)
                          throws CoreException
        Description copied from interface: AdaptrisMessageEncoder
        Encode the AdaptrisMessage object and write it to the supplied target
        Parameters:
        msg - the AdaptrisMessage to be encoded
        target - 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 an AdaptrisMessage 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.