Package org.apache.james.mime4j.internal
Class ParserStreamContentHandler
- java.lang.Object
-
- org.apache.james.mime4j.internal.ParserStreamContentHandler
-
- All Implemented Interfaces:
ContentHandler
public class ParserStreamContentHandler extends java.lang.Object implements ContentHandler
-
-
Field Summary
Fields Modifier and Type Field Description private BodyFactory
bodyFactory
private Entity
entity
private MessageImplFactory
messageImplFactory
private java.util.Stack<java.lang.Object>
stack
-
Constructor Summary
Constructors Constructor Description ParserStreamContentHandler(Entity entity, BodyFactory bodyFactory)
ParserStreamContentHandler(Entity entity, MessageImplFactory messageImplFactory, BodyFactory bodyFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
body(BodyDescriptor bd, java.io.InputStream is)
Called when the body of a discrete (non-multipart) entity is about to be parsed.void
endBodyPart()
Called when a body part ends.void
endHeader()
Called when there are no more header fields in a message or body part.void
endMessage()
Called when a message ends.void
endMultipart()
Called when the body of an entity has been parsed.void
epilogue(java.io.InputStream is)
Called for the epilogue (whatever comes after the final body part) of amultipart/*
entity.private void
expect(java.lang.Class<?> c)
void
field(Field field)
Called for each field of a header.private static ByteSequence
loadStream(java.io.InputStream in)
void
preamble(java.io.InputStream is)
Called for the preamble (whatever comes before the first body part) of amultipart/*
entity.void
raw(java.io.InputStream is)
Unsupported.void
startBodyPart()
Called when a new body part starts inside amultipart/*
entity.void
startHeader()
Called when a header (of a message or body part) is about to be parsed.void
startMessage()
Called when a new message starts (a top level message or an embedded rfc822 message).void
startMultipart(BodyDescriptor bd)
Called when the body of a multipart entity is about to be parsed.
-
-
-
Field Detail
-
entity
private final Entity entity
-
messageImplFactory
private final MessageImplFactory messageImplFactory
-
bodyFactory
private final BodyFactory bodyFactory
-
stack
private final java.util.Stack<java.lang.Object> stack
-
-
Constructor Detail
-
ParserStreamContentHandler
public ParserStreamContentHandler(Entity entity, BodyFactory bodyFactory)
-
ParserStreamContentHandler
public ParserStreamContentHandler(Entity entity, MessageImplFactory messageImplFactory, BodyFactory bodyFactory)
-
-
Method Detail
-
expect
private void expect(java.lang.Class<?> c)
-
startMessage
public void startMessage() throws MimeException
Description copied from interface:ContentHandler
Called when a new message starts (a top level message or an embedded rfc822 message).- Specified by:
startMessage
in interfaceContentHandler
- Throws:
MimeException
- on processing errors
-
endMessage
public void endMessage() throws MimeException
Description copied from interface:ContentHandler
Called when a message ends.- Specified by:
endMessage
in interfaceContentHandler
- Throws:
MimeException
- on processing errors
-
startHeader
public void startHeader() throws MimeException
Description copied from interface:ContentHandler
Called when a header (of a message or body part) is about to be parsed.- Specified by:
startHeader
in interfaceContentHandler
- Throws:
MimeException
- on processing errors
-
field
public void field(Field field) throws MimeException
Description copied from interface:ContentHandler
Called for each field of a header.- Specified by:
field
in interfaceContentHandler
- Parameters:
field
- the MIME field.- Throws:
MimeException
- on processing errors
-
endHeader
public void endHeader() throws MimeException
Description copied from interface:ContentHandler
Called when there are no more header fields in a message or body part.- Specified by:
endHeader
in interfaceContentHandler
- Throws:
MimeException
- on processing errors
-
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 interfaceContentHandler
- 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 theContent-Type
andContent-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 interfaceContentHandler
- Parameters:
bd
- seeContentHandler.startMultipart(BodyDescriptor)
is
- the contents of the body. NOTE: this is the raw body contents - it will not be decoded if encoded. Thebd
parameter should be used to determine how the stream data should be decoded.- Throws:
MimeException
- on processing errorsjava.io.IOException
- should be thrown on I/O errors.
-
endMultipart
public void endMultipart() throws MimeException
Description copied from interface:ContentHandler
Called when the body of an entity has been parsed.- Specified by:
endMultipart
in interfaceContentHandler
- Throws:
MimeException
- on processing errors
-
startBodyPart
public void startBodyPart() throws MimeException
Description copied from interface:ContentHandler
Called when a new body part starts inside amultipart/*
entity.- Specified by:
startBodyPart
in interfaceContentHandler
- Throws:
MimeException
- on processing errors
-
endBodyPart
public void endBodyPart() throws MimeException
Description copied from interface:ContentHandler
Called when a body part ends.- Specified by:
endBodyPart
in interfaceContentHandler
- Throws:
MimeException
- on processing 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 amultipart/*
entity.- Specified by:
epilogue
in interfaceContentHandler
- Parameters:
is
- used to get the contents of the epilogue.- Throws:
MimeException
- on processing errorsjava.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 amultipart/*
entity.- Specified by:
preamble
in interfaceContentHandler
- Parameters:
is
- used to get the contents of the preamble.- Throws:
MimeException
- on processing errorsjava.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 interfaceContentHandler
- Parameters:
is
- the raw contents of the entity.- Throws:
java.lang.UnsupportedOperationException
MimeException
- on processing errorsjava.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
-
-