Class ParserStreamContentHandler

  • All Implemented Interfaces:
    ContentHandler

    public class ParserStreamContentHandler
    extends java.lang.Object
    implements ContentHandler
    A ContentHandler for building an Entity to be used in conjunction with a MimeStreamParser.
    • Field Detail

      • entity

        private final Entity entity
      • stack

        private final java.util.Stack<java.lang.Object> stack
    • Method Detail

      • expect

        private void expect​(java.lang.Class<?> c)
      • startMultipart

        public void startMultipart​(BodyDescriptor bd)
                            throws MimeException
        Description copied from interface: ContentHandler
        Called when the body of a multipart entity is about to be parsed.
        Specified by:
        startMultipart in interface ContentHandler
        Parameters:
        bd - encapsulates the values (either read from the message stream or, if not present, determined implictly as described in the MIME rfc:s) of the Content-Type and Content-Transfer-Encoding header fields.
        Throws:
        MimeException - on processing errors
      • body

        public void body​(BodyDescriptor bd,
                         java.io.InputStream is)
                  throws MimeException,
                         java.io.IOException
        Description copied from interface: ContentHandler
        Called when the body of a discrete (non-multipart) entity is about to be parsed.
        Specified by:
        body in interface ContentHandler
        Parameters:
        bd - see ContentHandler.startMultipart(BodyDescriptor)
        is - the contents of the body. NOTE: this is the raw body contents - it will not be decoded if encoded. The bd parameter should be used to determine how the stream data should be decoded.
        Throws:
        MimeException - on processing errors
        java.io.IOException - should be thrown on I/O errors.
      • epilogue

        public void epilogue​(java.io.InputStream is)
                      throws MimeException,
                             java.io.IOException
        Description copied from interface: ContentHandler
        Called for the epilogue (whatever comes after the final body part) of a multipart/* entity.
        Specified by:
        epilogue in interface ContentHandler
        Parameters:
        is - used to get the contents of the epilogue.
        Throws:
        MimeException - on processing errors
        java.io.IOException - should be thrown on I/O errors.
      • preamble

        public void preamble​(java.io.InputStream is)
                      throws MimeException,
                             java.io.IOException
        Description copied from interface: ContentHandler
        Called for the preamble (whatever comes before the first body part) of a multipart/* entity.
        Specified by:
        preamble in interface ContentHandler
        Parameters:
        is - used to get the contents of the preamble.
        Throws:
        MimeException - on processing errors
        java.io.IOException - should be thrown on I/O errors.
      • raw

        public void raw​(java.io.InputStream is)
                 throws MimeException,
                        java.io.IOException
        Unsupported.
        Specified by:
        raw in interface ContentHandler
        Parameters:
        is - the raw contents of the entity.
        Throws:
        java.lang.UnsupportedOperationException
        MimeException - on processing errors
        java.io.IOException - should be thrown on I/O errors.
        See Also:
        MimeStreamParser.setRaw()
      • loadStream

        private static ByteSequence loadStream​(java.io.InputStream in)
                                        throws java.io.IOException
        Throws:
        java.io.IOException