org.apache.james.mime4j.parser
public class MimeStreamParser extends java.lang.Object
Parses MIME (or RFC822) message streams of bytes or characters and reports
parsing events to a ContentHandler
instance.
Typical usage:
ContentHandler handler = new MyHandler(); MimeStreamParser parser = new MimeStreamParser(); parser.setContentHandler(handler); parser.parse(new FileInputStream("mime.msg"));
Constructor and Description |
---|
MimeStreamParser() |
MimeStreamParser(MimeEntityConfig config) |
Modifier and Type | Method and Description |
---|---|
boolean |
isContentDecoding()
Determines whether this parser automatically decodes body content
based on the on the MIME fields with the standard defaults.
|
boolean |
isRaw()
Determines if this parser is currently in raw mode.
|
void |
parse(java.io.InputStream is)
Parses a stream of bytes containing a MIME message.
|
void |
setContentDecoding(boolean b)
Defines whether parser should automatically decode body content
based on the on the MIME fields with the standard defaults.
|
void |
setContentHandler(ContentHandler h)
Sets the
ContentHandler to use when reporting
parsing events. |
void |
setRaw(boolean raw)
Enables or disables raw mode.
|
void |
stop()
Finishes the parsing and stops reading lines.
|
public MimeStreamParser(MimeEntityConfig config)
public MimeStreamParser()
public boolean isContentDecoding()
public void setContentDecoding(boolean b)
public void parse(java.io.InputStream is) throws MimeException, java.io.IOException
is
- the stream to parse.MimeException
- if the message can not be processedjava.io.IOException
- on I/O errors.public boolean isRaw()
true
if in raw mode, false
otherwise.setRaw(boolean)
public void setRaw(boolean raw)
ContentHandler.raw(InputStream)
handler method only.
The stream will contain the entire unparsed entity contents
including header fields and whatever is in the body.raw
- true
enables raw mode, false
disables it.public void stop()
ContentHandler.endMultipart()
,
ContentHandler.endBodyPart()
,
ContentHandler.endMessage()
, etc to match previous calls
to
ContentHandler.startMultipart(BodyDescriptor)
,
ContentHandler.startBodyPart()
,
ContentHandler.startMessage()
, etc.public void setContentHandler(ContentHandler h)
ContentHandler
to use when reporting
parsing events.h
- the ContentHandler
.Copyright © 2004-2016. All Rights Reserved.