|
ePOST API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rice.email.proxy.util.MimeParser
public class MimeParser
originally from http://www.nsftools.com/tips/MimeParser.java
Field Summary | |
---|---|
protected java.util.Stack |
boundaries
The stack of all boundaries |
protected byte[] |
boundary
|
protected byte[] |
buffer
The internal buffer used to store the parsed data |
static int |
BUFFER_SIZE
The initial size of the buffer to use |
protected int |
bufferLength
|
static int |
END_DOCUMENT
|
static int |
END_MULTIPART
|
protected int |
event
The current event |
protected byte[] |
header
The parsed header, part, and boundary data, if it exists |
protected java.io.InputStream |
in
Where we are reading the data from |
protected byte[] |
part
|
static int |
SINGLE_PART
|
static int |
START_DOCUMENT
static flags reporting the type of event just hit |
static int |
START_HEADERS_PART
|
static int |
START_MULTIPART
|
Constructor Summary | |
---|---|
MimeParser(java.io.InputStream inStream)
The sole constructor for this class, which takes any kind of InputStream as a parameter. |
Method Summary | |
---|---|
protected void |
appendToBuffer(byte b)
Internal method which appends a byte to the internal buffer |
protected void |
assertEvent(int e)
An assertion method |
java.lang.String |
getBoundary()
Get the boundary that we're breaking the message up on |
java.lang.String |
getCurrentBoundary()
Returns the current boundary |
int |
getEventType()
Returns the type of the current event |
byte[] |
getHeader()
Get the header of the current message part that we're looking at |
java.lang.String |
getHeaderValue(java.lang.String entry)
Gets the specified value from a specified header, or null if the entry does not exist |
byte[] |
getPart()
Gets the data contained in the current message part as a byte array (this will return an empty byte array if you've already got the data from this message part) |
protected boolean |
isBoundary()
Method which returns whether or not we've actually hit a boundary |
protected boolean |
isEndBoundary()
Method which returns whether or not we've actually hit a boundary |
static void |
main(java.lang.String[] args)
A simple main method, in case you want to test the basic functionality of this class by running it stand-alone. |
int |
next()
Advances to the next part of the message, if there is a next part. |
protected void |
parseBoundary()
Internal method for parsing a MIME boundary |
protected void |
parseHeader()
A private method to get the next header block on the InputStream. |
protected void |
parsePart()
Internal method which parses and stores the given part. |
protected java.lang.String |
retrieveBoundary()
A private method to attempt to read the MIME boundary from the Content-Type entry in the first header it finds. |
protected boolean |
startsWith(byte[] array,
java.lang.String s)
Internal method for startsWith |
protected void |
storeBoundary()
Internal method which grabs the MIME boundary from the current line in the buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int START_DOCUMENT
public static final int START_HEADERS_PART
public static final int START_MULTIPART
public static final int END_MULTIPART
public static final int END_DOCUMENT
public static final int SINGLE_PART
public static final int BUFFER_SIZE
protected java.io.InputStream in
protected int event
protected byte[] buffer
protected int bufferLength
protected byte[] header
protected byte[] part
protected byte[] boundary
protected java.util.Stack boundaries
Constructor Detail |
---|
public MimeParser(java.io.InputStream inStream)
inStream
- an InputStream that contains a Multi-part MIME messageMethod Detail |
---|
public int getEventType()
public int next() throws MimeException
MimeException
public java.lang.String getCurrentBoundary()
public java.lang.String getBoundary() throws MimeException
MimeException
public byte[] getHeader() throws MimeException
MimeException
public byte[] getPart() throws MimeException
MimeException
public java.lang.String getHeaderValue(java.lang.String entry) throws MimeException
header
- the header to look atentry
- the name of the entry you're looking for
MimeException
protected void assertEvent(int e) throws MimeException
the
- expected event
MimeException
protected boolean isBoundary()
protected boolean isEndBoundary()
protected java.lang.String retrieveBoundary() throws MimeException
MimeException
protected void parseBoundary() throws MimeException
MimeException
protected void storeBoundary()
protected void parseHeader() throws MimeException
MimeException
protected void parsePart() throws MimeException
MimeException
protected boolean startsWith(byte[] array, java.lang.String s)
byte[]
- THe arrays
- The stirngprotected void appendToBuffer(byte b)
b
- The bytepublic static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
ePOST API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |