Class DefaultMessageWriter

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static byte[] CRLF  
      private static byte[] DASHES  
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultMessageWriter()
      Protected constructor prevents direct instantiation.
    • Field Detail

      • CRLF

        private static final byte[] CRLF
      • DASHES

        private static final byte[] DASHES
    • Constructor Detail

      • DefaultMessageWriter

        public DefaultMessageWriter()
        Protected constructor prevents direct instantiation.
    • Method Detail

      • asBytes

        public static byte[] asBytes​(Message message)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBody

        public void writeBody​(Body body,
                              java.io.OutputStream out)
                       throws java.io.IOException
        Write the specified Body to the specified OutputStream.
        Specified by:
        writeBody in interface MessageWriter
        Parameters:
        body - the Body to write.
        out - the OutputStream to write to.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • writeEntity

        public void writeEntity​(Entity entity,
                                java.io.OutputStream out)
                         throws java.io.IOException
        Write the specified Entity to the specified OutputStream.
        Specified by:
        writeEntity in interface MessageWriter
        Parameters:
        entity - the Entity to write.
        out - the OutputStream to write to.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • writeMessage

        public void writeMessage​(Message message,
                                 java.io.OutputStream out)
                          throws java.io.IOException
        Write the specified Message to the specified OutputStream.
        Specified by:
        writeMessage in interface MessageWriter
        Parameters:
        message - the Message to write.
        out - the OutputStream to write to.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • writeMultipart

        public void writeMultipart​(Multipart multipart,
                                   java.io.OutputStream out)
                            throws java.io.IOException
        Write the specified Multipart to the specified OutputStream.
        Specified by:
        writeMultipart in interface MessageWriter
        Parameters:
        multipart - the Multipart to write.
        out - the OutputStream to write to.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • writeField

        public void writeField​(Field field,
                               java.io.OutputStream out)
                        throws java.io.IOException
        Write the specified Field to the specified OutputStream.
        Specified by:
        writeField in interface MessageWriter
        Parameters:
        field - the Field to write.
        out - the OutputStream to write to.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • writeHeader

        public void writeHeader​(Header header,
                                java.io.OutputStream out)
                         throws java.io.IOException
        Write the specified Header to the specified OutputStream.
        Specified by:
        writeHeader in interface MessageWriter
        Parameters:
        header - the Header to write.
        out - the OutputStream to write to.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • encodeStream

        protected java.io.OutputStream encodeStream​(java.io.OutputStream out,
                                                    java.lang.String encoding,
                                                    boolean binaryBody)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBytes

        private void writeBytes​(ByteSequence byteSequence,
                                java.io.OutputStream out)
                         throws java.io.IOException
        Throws:
        java.io.IOException