org.apache.james.mime4j.message
Class SimpleContentHandler

java.lang.Object
  extended by org.apache.james.mime4j.parser.AbstractContentHandler
      extended by org.apache.james.mime4j.message.SimpleContentHandler
All Implemented Interfaces:
ContentHandler

public abstract class SimpleContentHandler
extends AbstractContentHandler

Abstract implementation of ContentHandler that automates common tasks. Currently performs header parsing and applies content-transfer decoding to body parts.


Constructor Summary
SimpleContentHandler()
           
 
Method Summary
 void body(BodyDescriptor bd, java.io.InputStream is)
          Called when the body of a discrete (non-multipart) entity is about to be parsed.
abstract  void bodyDecoded(BodyDescriptor bd, java.io.InputStream is)
          Called when the body of a discrete (non-multipart) entity is encountered.
 void endHeader()
          Called when there are no more header fields in a message or body part.
 void field(Field field)
          Called for each field of a header.
abstract  void headers(Header header)
          Called after headers are parsed.
 void startHeader()
          Called when a header (of a message or body part) is about to be parsed.
 
Methods inherited from class org.apache.james.mime4j.parser.AbstractContentHandler
endBodyPart, endMessage, endMultipart, epilogue, preamble, raw, startBodyPart, startMessage, startMultipart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleContentHandler

public SimpleContentHandler()
Method Detail

headers

public abstract void headers(Header header)
Called after headers are parsed.


bodyDecoded

public abstract void bodyDecoded(BodyDescriptor bd,
                                 java.io.InputStream is)
                          throws java.io.IOException
Called when the body of a discrete (non-multipart) entity is encountered.

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.
is - the contents of the body. Base64 or quoted-printable decoding will be applied transparently.
Throws:
java.io.IOException - should be thrown on I/O errors.

startHeader

public final void startHeader()
Description copied from interface: ContentHandler
Called when a header (of a message or body part) is about to be parsed.

Specified by:
startHeader in interface ContentHandler
Overrides:
startHeader in class AbstractContentHandler
See Also:
AbstractContentHandler.startHeader()

field

public final void field(Field field)
                 throws MimeException
Description copied from interface: ContentHandler
Called for each field of a header.

Specified by:
field in interface ContentHandler
Overrides:
field in class AbstractContentHandler
Parameters:
field - the MIME field.
Throws:
MimeException - on processing errors
See Also:
AbstractContentHandler.field(Field)

endHeader

public final void endHeader()
Description copied from interface: ContentHandler
Called when there are no more header fields in a message or body part.

Specified by:
endHeader in interface ContentHandler
Overrides:
endHeader in class AbstractContentHandler
See Also:
AbstractContentHandler.endHeader()

body

public final void body(BodyDescriptor bd,
                       java.io.InputStream is)
                throws 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
Overrides:
body in class AbstractContentHandler
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:
java.io.IOException - should be thrown on I/O errors.
See Also:
AbstractContentHandler.body(org.apache.james.mime4j.descriptor.BodyDescriptor, java.io.InputStream)


Copyright © 2004-2013. All Rights Reserved.