public final class StructureMailMessageParser
extends java.lang.Object
StructureMailMessageParser
- A callback parser to parse instances of MailMessage
by invoking the handleXXX()
methods of given MailMessageHandler
objectConstructor and Description |
---|
StructureMailMessageParser()
Constructor
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
generateFilename(java.lang.String sequenceId,
java.lang.String baseMimeType)
Generates a filename consisting of common prefix "Part_" and part's sequence ID appended
|
static java.lang.String |
getFileName(java.lang.String rawFileName,
java.lang.String sequenceId,
java.lang.String baseMimeType)
Generates an appropriate filename from either specified
rawFileName if not null or generates a filename
composed with "Part_" + sequenceId |
static java.lang.String |
getSequenceId(java.lang.String prefix,
int partCount)
Composes part's sequence ID from given prefix and part's count
|
void |
parseMailMessage(MailMessage mail,
StructureHandler handler)
Parses specified mail using given handler as call-back
|
void |
parseMailMessage(MailMessage mail,
StructureHandler handler,
java.lang.String prefix)
Parses specified mail using given handler as call-back and given initial prefix for mail part identifiers; e.g.
|
StructureMailMessageParser |
reset()
Resets this parser and returns itself
|
StructureMailMessageParser |
setInlineDetectorBehavior(boolean strict)
Switches the INLINE detector behavior.
|
StructureMailMessageParser |
setNeverTreatMessageAsAttachment(boolean neverTreatMessageAsAttachment)
Sets the behavior how to handle a message part.
|
StructureMailMessageParser |
setParseTNEFParts(boolean parseTNEFParts)
Sets whether TNEF parts should be parsed or not.
|
StructureMailMessageParser |
setParseUUEncodedParts(boolean parseUUEncodedParts)
Sets whether UUEncoded parts should be parsed or not.
|
public StructureMailMessageParser setNeverTreatMessageAsAttachment(boolean neverTreatMessageAsAttachment)
neverTreatMessageAsAttachment
- whether to treat a message part as an attachmentpublic StructureMailMessageParser setInlineDetectorBehavior(boolean strict)
strict
- true
to perform strict INLINE detector behavior; otherwise false
public StructureMailMessageParser setParseTNEFParts(boolean parseTNEFParts)
parseTNEFParts
- true
to parse TNEF parts; otherwise false
public StructureMailMessageParser setParseUUEncodedParts(boolean parseUUEncodedParts)
parseUUEncodedParts
- true
to parse UUEncoded parts; otherwise false
public StructureMailMessageParser reset()
public void parseMailMessage(MailMessage mail, StructureHandler handler) throws com.openexchange.exception.OXException
mail
- The mail to parsehandler
- The call-back handlercom.openexchange.exception.OXException
- If parsing specified mail failspublic void parseMailMessage(MailMessage mail, StructureHandler handler, java.lang.String prefix) throws com.openexchange.exception.OXException
"1.1"
.mail
- The mail to parsehandler
- The call-back handlerprefix
- The initial prefix for mail part identifiers; e.g. "1.1"
com.openexchange.exception.OXException
- If parsing specified mail failspublic static java.lang.String getFileName(java.lang.String rawFileName, java.lang.String sequenceId, java.lang.String baseMimeType)
rawFileName
if not null
or generates a filename
composed with "Part_" + sequenceId
rawFileName
- The raw filename obtained from mail partsequenceId
- The part's sequence IDbaseMimeType
- The base MIME type to look up an appropriate file extension, if rawFileName
is null
public static java.lang.String getSequenceId(java.lang.String prefix, int partCount)
prefix
- The prefix (may be null
)partCount
- The part countpublic static java.lang.String generateFilename(java.lang.String sequenceId, java.lang.String baseMimeType)
sequenceId
- Part's sequence IDbaseMimeType
- The base MIME type to look up an appropriate file extension if rawFileName
is null