java.lang.Object
org.jvnet.mimepull.DataHead
Represents an attachment part in a MIME message. MIME message parsing is done
lazily using a pull parser, so the part may not have all the data.
read()
and readOnce
may trigger the actual parsing the message. In fact,
parsing of an attachment part may be triggered by calling read()
methods
on some other attachment parts. All this happens behind the scenes so the
application developer need not worry about these details.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
(package private) final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Throwable
Used only for debugging.(package private) DataFile
If the part is stored in a file, non-null.(package private) Chunk
Linked list to keep the part's content(package private) long
private final MIMEPart
(package private) boolean
(package private) Chunk
Linked list to keep the part's content -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
addBody
(ByteBuffer buf) (package private) void
close()
(package private) void
(package private) void
read()
Can get the attachment part's content multiple times.readOnce()
Can get the attachment part's content only once.private boolean
Used for an assertion.
-
Field Details
-
head
Linked list to keep the part's content -
tail
Linked list to keep the part's content -
dataFile
DataFile dataFileIf the part is stored in a file, non-null. -
part
-
readOnce
boolean readOnce -
inMemory
volatile long inMemory -
consumedAt
Used only for debugging. This records where readOnce() is called.
-
-
Constructor Details
-
DataHead
DataHead(MIMEPart part)
-
-
Method Details
-
addBody
-
doneParsing
void doneParsing() -
moveTo
-
close
void close() -
read
Can get the attachment part's content multiple times. That means the full content needs to be there in memory or on the file system. Calling this method would trigger parsing for the part's data. So do not call this unless it is required(otherwise, just wrap MIMEPart into a object that returns InputStream for e.g DataHandler)- Returns:
- data for the part's content
-
unconsumed
private boolean unconsumed()Used for an assertion. Returns true when readOnce() is not already called. or otherwise throw an exception.Calling this method also marks the stream as 'consumed'
- Returns:
- true if readOnce() is not called before
-
readOnce
Can get the attachment part's content only once. The content will be lost after the method. Content data is not be stored on the file system or is not kept in the memory for the following case: - Attachement parts contents are accessed sequentially In general, take advantage of this when the data is used only once.- Returns:
- data for the part's content
-