|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--de.trantor.mail.MimeDecoder
Is a helper class for decoding MIME data contained in e-mail messages. As the name implies, MimeDecoder allows a kind of read-only view of the MIME parts contained in a message, giving access to textual as well as binary content.
Every MimeDecoder works on and thus represents exactly one MIME part, which according to RFC 2045 - RFC 2049 may be either of the following two:
Please note that a MimeDecoder is not notified of any changes to the underlying message it is working on, so changes to the message will make the MimeDecoder invalid. A new MimeDecoder should be created after changes have been applied. Otherwise the results are unpredictable and will most probably result in some kind of Exception.
One could argue that there should be a closer integration between the Message and the MimeDecoder classes that is able to handle these changes. The rationale for the given implementation is - again - memory savings. The MimeDecoder is actually an optional component that *can* be used on a Message if the application demands it. The Message class, on the other hand, is not dependent on the MimeDecoder at all, which means that the Message class can be deployed without having to deploy the MimeDecoder class, too.
A short note for implementators that want to understand the internal structure of the MimeDecoder class: The basic idea is that the MimeDecoder holds a direct reference to the message's Vector of lines (both header and body) as well as two integer fields telling where the part represented by the MimeDecoder starts and ends. In case of multi-parts, an additonal Vector holds all the occurences of the part boundary string, which makes it quite easy to create additional MimeDecoders for the subordinate MIME parts.
Message,
MimeDecoder(Message),
getBodyLine(int),
getBodyBytes(),
getPart(int)| Constructor Summary | |
MimeDecoder(Message message)
Creates a new MimeDecoder for a given message. |
|
| Method Summary | |
byte[] |
getBodyBytes()
Returns the binary data contained in this MIME part. |
java.lang.String |
getBodyLine(int index)
Returns a line of this MIME part's body its index. |
int |
getBodyLineCount()
Returns the number of lines in this MIME part's body. |
java.lang.String |
getEncoding()
Returns the encoding of this MIME part, which is deduced from the "Content-Transfer-Encoding:" header field. |
java.lang.String |
getName()
Returns the filename of this MIME part, which is deduced from the "name=" sub-field of the "Content-Type:" header field. |
MimeDecoder |
getPart(int index)
Returns a subordinate part of this MIME part. |
int |
getPartCount()
Returns the number of MIME parts that constitute this MIME part. |
static java.lang.String |
getStringName(java.lang.String s)
Returns the name contained in a name/value pair string. |
static java.lang.String |
getStringValue(java.lang.String s)
Returns the value contained in a name/value pair string. |
java.lang.String |
getType()
Returns the type of this MIME part, which is deduced from the "Content-Type:" header field. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MimeDecoder(Message message)
getBodyLine(int),
getBodyBytes()| Method Detail |
public int getBodyLineCount()
getBodyLine(int),
getBodyBytes()
public java.lang.String getBodyLine(int index)
throws java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsExceptiongetBodyLineCount(),
getBodyBytes()public byte[] getBodyBytes()
public int getPartCount()
public MimeDecoder getPart(int index)
public java.lang.String getType()
getEncoding(),
getName()public java.lang.String getName()
getType(),
getEncoding()public java.lang.String getEncoding()
public static java.lang.String getStringName(java.lang.String s)
Note that this method is different from the getStringName() method of the Message class due to the different separator character.
getStringValue(java.lang.String),
Message.getStringName(java.lang.String)public static java.lang.String getStringValue(java.lang.String s)
Note that this method is different from the getStringValue() method of the Message class due to the different separator character.
getStringName(java.lang.String),
Message.getStringValue(java.lang.String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||