|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.hunnysoft.jmime.Node
com.hunnysoft.jmime.Body
public class Body
Class that represents the body of a message or body part.
Body represents a body, as described in RFC 2045. A
body is always part of an entity, which may be either a
message or a body part. If the content type of an
entity is "multipart/*", then the body contains one or more body parts.
If the content type is "message/rfc822", then the body contains an
encapsulated message. For all other content types, the body contains a
string of bytes, which may be text or some other kind of binary
data..
In Hunny JMIME, a Body object is contained in an Entity object. The Body object may contain a discrete
body consisting only of a string of bytes, or it may be a composite
body, consisting of several contained BodyPart objects or a
single contained Message object. The only reliable way to
determine the type of Body is to access the
Content-Type header field from the Headers object of
the Entity that contains it. For this reason, a
Body should always be part of a Entity.
In the document tree representation of a message, a
Body object can be an intermediate node, having both a
parent node and one or more child nodes, or a leaf node, having a parent
but no child nodes. In either case, the parent node is the Entity object that contains it. If it is an intermediate node, it must
be of type "multipart/*" with BodyPart objects as child nodes,
or of type "message/rfc822" with a single Message object as its
child node. (See the documentation for Node for a discussion of
the tree representation of a message.)
Normally, you do not create a Body object directly, but
you access it through the Entity.body() method of Entity,
which creates the Body object for you.
To add a BodyPart to a multipart Body, call the
addBodyPart(BodyPart) method or insertBodyPartAt(int,BodyPart) method. To get the number of body
parts, call numBodyParts(). To access a particular body part,
call bodyPartAt(int). To remove a single body part, call
removeBodyPartAt(int). To remove and delete all body parts,
call deleteAllBodyParts().
To get the Message object contained in a Body
object with "message/rfc822" content type, call message(). To
set the contained message, call setMessage(Message).
| Field Summary |
|---|
| Fields inherited from class com.hunnysoft.jmime.Node |
|---|
mIsModified, mParent, mString |
| Constructor Summary | |
|---|---|
Body()
Default constructor. |
|
Body(Body other)
Copy constructor. |
|
Body(ByteString bstr)
Constructor that takes an initial byte string argument. |
|
| Method Summary | |
|---|---|
void |
_parse(int depth)
|
void |
addBodyPart(BodyPart part)
Adds a body part to the end of the list. |
void |
assemble()
Assembles the string representation. |
BodyPart |
bodyPartAt(int index)
Gets the body part at the specified position. |
java.lang.Object |
clone()
Creates a copy of this object. |
void |
deleteAllBodyParts()
Deletes all body parts in the list. |
ByteString |
epilogue()
Gets the epilogue of a multipart body. |
void |
insertBodyPartAt(int index,
BodyPart part)
Inserts a body part at the specified position. |
Message |
message()
Gets the contained message (for type "message/rfc822" only). |
int |
numBodyParts()
Gets the number of body parts in the list. |
void |
parse()
Parses the string representation. |
ByteString |
preamble()
Gets the preamble of a multipart body. |
BodyPart |
removeBodyPartAt(int index)
Removes the body part at the specified position. |
void |
setEpilogue(ByteString epilogue)
Sets the epilogue of a multipart body. |
void |
setMessage(Message message)
Sets the contained message (for type "message/rfc822" only). |
void |
setPreamble(ByteString preamble)
Sets the preamble of a multipart body. |
| Methods inherited from class com.hunnysoft.jmime.Node |
|---|
_setString, isModified, parent, setModified, setParent, setString, string, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Body()
This constructor sets the Body object's string
representation to the empty string and sets its parent node to
null.
public Body(Body other)
This constructor performs a deep copy of its argument. The
parent node of the new Body object is set to
null.
other - Body instance to copypublic Body(ByteString bstr)
This constructor sets the Body object's string
representation to bstr and sets its parent node to
null.
Normally, you call the parse() method immediately after
this constructor to create the broken-down representation.
bstr - initial value for the string representation| Method Detail |
|---|
public java.lang.Object clone()
This method, inherited from Object, creates a new
Body object that has the same value as this
Body object. The parent node of the new
Body object is set to null.
clone in class Nodepublic void parse()
This method, inherited from Node, executes the parse
operation for Body objects. The parse operation
creates or updates the broken-down representation from the string
representation. For a multipart Body object, the parse
method creates a collection of BodyPart objects. For a
message/rfc822 Body, the parse method creates a single
Message object. For any other type of Body,
the parse method does nothing.
This method calls the parse() method of any objects
it creates.
You should call this method after you set or modify the string
representation, and before you access a contained
BodyPart or Message.
This method clears the is-modified flag.
Note: If the Body object has no parent node -- that
is, it is not contained by an Entity object -- then the
parse method does nothing, since it is unable to determine the type
of body.
parse in class NodeNode.assemble()public void _parse(int depth)
public void assemble()
This method, inherited from Node, executes the assemble
operation for Body objects. The assemble operation
creates or updates the string representation from the broken-down
representation. Only Body objects with content type of
"multipart/*" or "message/rfc822" require assembling. In either
case, the Body object must be able to find the headers
of the message or body part that contains it. Therefore, if the
Body object is not the child of an Entity (that
is, a Message or BodyPart) object, the
Body cannot be assembled because the content type
cannot be determined.
This method calls the assemble() method of any
BodyPart or Message object it contains.
You should call this method after you add a BodyPart
object to a "multipart/*" body, or add a Message object to a
"message/rfc822" body, and before you access the object's string
representation.
This method clears the is-modified flag.
assemble in class NodeNode.parse()public int numBodyParts()
public void addBodyPart(BodyPart part)
part - BodyPart object to addpublic void deleteAllBodyParts()
public BodyPart bodyPartAt(int index)
index - position of the BodyPart object to get
(0 <= index < numBodyParts())
BodyPart object at the specified position
java.lang.IndexOutOfBoundsException - if index is out of range
public void insertBodyPartAt(int index,
BodyPart part)
Inserting at position 0 inserts the body part at the beginning.
Inserting at position numBodyParts() appends the body
part to the end.
index - position in list to insert the BodyPart object
(0 <= index <= numBodyParts())part - BodyPart object to insert
java.lang.IndexOutOfBoundsException - if index is out of rangepublic BodyPart removeBodyPartAt(int index)
index - position of the BodyPart object to remove
(0 <= index < numBodyParts())
BodyPart object
java.lang.IndexOutOfBoundsException - if index is out of rangepublic Message message()
If the media type of the message or body part that contains this body is "message/rfc822", then the body contains an encapsulated message. Use this method to get the encapsulated message.
Message object; or null if
there is no Message objectpublic void setMessage(Message message)
message - the Message objectpublic ByteString preamble()
The preamble (a term from the MIME standard) is the optional text that appears before the first boundary in a multipart message. The text typically contains a message intended for users who use mail user agents that do not support MIME. In many cases, the preamble is empty.
public void setPreamble(ByteString preamble)
preamble - the preamble of the bodypublic ByteString epilogue()
The epilogue (a term from the MIME standard) is the optional text that appears after the final boundary in a multipart message. In most cases, the epilogue is empty. Any use of the epilogue by applications is non-standard.
public void setEpilogue(ByteString epilogue)
epilogue - the epilogue of the body
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||