Skip navigation links
com.adaptris.util.text.mime

Class MultiPartOutput

    • Constructor Detail

      • MultiPartOutput

        public MultiPartOutput(java.lang.String mimeId)
                        throws javax.mail.MessagingException
        Constructor.

        This implicitly sets the multipart sub-type to be mixed.

        Parameters:
        mimeId - the Message-ID header to assign to this multi-part
        Throws:
        javax.mail.MessagingException - if the bytes did not contain a valid MimeMultiPart
      • MultiPartOutput

        public MultiPartOutput(java.lang.String mimeId,
                               java.lang.String subtype)
                        throws javax.mail.MessagingException
        Constructor.
        Parameters:
        mimeId - the Message-ID header to assign to this multi-part
        subtype - the multi-part subtype.
        Throws:
        javax.mail.MessagingException - if there was a failure to create the underlying Mime Multipart
    • Method Detail

      • addPart

        public void addPart(java.lang.String payload,
                            java.lang.String encoding,
                            java.lang.String contentId)
                     throws javax.mail.MessagingException,
                            java.io.IOException
        Add a new part to the mime multipart.
        Parameters:
        payload - the data.
        encoding - the encoding to apply
        contentId - the id to set the content with.
        Throws:
        javax.mail.MessagingException - if there was a failure adding the part. MimeMultiPart
        java.io.IOException - if there was an IOException
      • addPart

        public void addPart(java.lang.String payload,
                            java.lang.String contentId)
                     throws javax.mail.MessagingException,
                            java.io.IOException
        Add a new part to the mime multipart.
        Parameters:
        payload - the data.
        contentId - the id to set the content with.
        Throws:
        javax.mail.MessagingException - if there was a failure adding the part. MimeMultiPart
        java.io.IOException - if there was an IOException
      • addPart

        public void addPart(byte[] payload,
                            java.lang.String contentId)
                     throws javax.mail.MessagingException,
                            java.io.IOException
        Add a new part to the mime multipart.
        Parameters:
        payload - the data.
        contentId - the id to set the content with.
        Throws:
        javax.mail.MessagingException - if there was a failure adding the part. MimeMultiPart
        java.io.IOException - if there was an IOException
      • addPart

        public void addPart(byte[] payload,
                            java.lang.String encoding,
                            java.lang.String contentId)
                     throws javax.mail.MessagingException,
                            java.io.IOException
        Add a new part to the mime multipart.
        Parameters:
        payload - the data.
        encoding - the encoding to apply
        contentId - the id to set the content with.
        Throws:
        javax.mail.MessagingException - on error manipulating the bodypart
        java.io.IOException - on general IO error.
      • addPart

        public void addPart(javax.mail.internet.MimeBodyPart part,
                            java.lang.String contentId)
                     throws javax.mail.MessagingException,
                            java.io.IOException
        Add a new part to the mime multipart.
        Parameters:
        part - an already existing mimebody part
        contentId - the id to set the content with.
        Throws:
        javax.mail.MessagingException - on error manipulating the bodypart
        java.io.IOException - on general IO error.
      • removePart

        public void removePart(java.lang.String contentId)
                        throws javax.mail.MessagingException,
                               java.io.IOException
        Remove a part from this multipart output.

        If non-unique content-id's are used for each bodypart, then an invocation of removePart(String) will remove all matching body parts.

        Parameters:
        contentId - the content-id associated with a previously added part.
        Throws:
        javax.mail.MessagingException - if there was a failure removing the part.
        java.io.IOException - if there was an IOException
      • getBytes

        public byte[] getBytes()
                        throws javax.mail.MessagingException,
                               java.io.IOException
        Get bytes created by this multi-part.
        Returns:
        the bytes represented by this MimeMultipartOutput
        Throws:
        javax.mail.MessagingException - if there was a failure retrieving the bytes.
        java.io.IOException - if there was an IOException
      • writeTo

        public void writeTo(java.io.OutputStream out)
                     throws javax.mail.MessagingException,
                            java.io.IOException
        Write the multipart to the given output stream.
        Parameters:
        out - the output stream.
        Throws:
        javax.mail.MessagingException - if there was a failure retrieving the bytes.
        java.io.IOException - if there was an IOException
      • writeTo

        public void writeTo(java.io.OutputStream out,
                            java.io.File tempFile)
                     throws javax.mail.MessagingException,
                            java.io.IOException
        Write the multipart to the given outputstream.
        Parameters:
        out - the output stream.
        tempFile - if not null, then use the specified file to stream the parts to first.
        Throws:
        javax.mail.MessagingException
        java.io.IOException
      • setHeader

        public void setHeader(java.lang.String key,
                              java.lang.String value)
        Set an arbitary header to the headers prefixed to the start of the multipart.

        The Content-Type and Content-Length will always be overridden with the content-type and length of the mime multipart

        Parameters:
        key - the key
        value - the value.
        See Also:
        InternetHeaders
      • getMimeHeader

        public javax.mail.internet.InternetHeaders getMimeHeader()
        Return the underlying mime header that will be used to write the headers.
        Returns:
        the internet header.