java.lang.Object
org.jvnet.mimepull.MIMEMessage
- All Implemented Interfaces:
Closeable
,AutoCloseable
Represents MIME message. MIME message parsing is done lazily using a
pull parser.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) MIMEConfig
private int
private MIMEPart
private final InputStream
private static final Logger
private boolean
-
Constructor Summary
ConstructorsConstructorDescriptionMIMEMessage
(InputStream in, String boundary) MIMEMessage
(InputStream in, String boundary, MIMEConfig config) Creates a MIME message from the content's stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes all parsedparts
and cleans up any resources that are held by thisMIMEMessage
(for e.g.private void
close
(Collection<MIMEPart> parts) Gets all the attachments by parsing the entire MIME message.private MIMEPart
getDecodedCidPart
(String cid) getPart
(int index) Creates nth attachment lazily.Creates a lazy attachment for a given Content-ID.boolean
Parses the MIME message in a pull fashion.final void
parseAll()
Parses the whole MIME message eagerly
-
Field Details
-
LOGGER
-
config
MIMEConfig config -
in
-
it
-
parsed
private boolean parsed -
currentPart
-
currentIndex
private int currentIndex -
partsList
-
partsMap
-
-
Constructor Details
-
MIMEMessage
- Parameters:
in
- MIME message streamboundary
- the separator for parts(pass it without --)- See Also:
-
MIMEMessage
Creates a MIME message from the content's stream. The content stream is closed when EOF is reached.- Parameters:
in
- MIME message streamboundary
- the separator for parts(pass it without --)config
- various configuration parameters
-
-
Method Details
-
getAttachments
Gets all the attachments by parsing the entire MIME message. Avoid this if possible since it is an expensive operation.- Returns:
- list of attachments.
-
getPart
Creates nth attachment lazily. It doesn't validate if the message has so many attachments. To do the validation, the message needs to be parsed. The parsing of the message is done lazily and is done while reading the bytes of the part.- Parameters:
index
- sequential order of the part. starts with zero.- Returns:
- attachemnt part
-
getPart
Creates a lazy attachment for a given Content-ID. It doesn't validate if the message contains an attachment with the given Content-ID. To do the validation, the message needs to be parsed. The parsing of the message is done lazily and is done while reading the bytes of the part.- Parameters:
contentId
- Content-ID of the part, expects Content-ID without<, >
- Returns:
- attachemnt part
-
getDecodedCidPart
-
parseAll
public final void parseAll()Parses the whole MIME message eagerly -
close
public void close()Closes all parsedparts
and cleans up any resources that are held by thisMIMEMessage
(for e.g. deletes temp files). This method is safe to call even if parsing of message failed.Does not throw
MIMEParsingException
if an error occurred during closing a MIME part. The exception (if any) is still logged.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
close
-
makeProgress
public boolean makeProgress()Parses the MIME message in a pull fashion.- Returns:
- false if the parsing is completed.
-