|
||||||||
| 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.FieldBody
public class FieldBody
Class that represents a header field body.
FieldBody represents a header field body in an RFC 2822
message or MIME body part. It is a base class that defines the
interface common to all structured and unstructured field bodies.
In the document tree representation of a message, a
FieldBody object may be either a leaf node, having a parent
node but no child nodes, or an intermediate node, having both a parent
node and one or more child nodes. The parent node is the Field
object that contains it. The child nodes, if present, depend on the
particular subclass of FieldBody. An
AddressList object, for example, has Address
objects as its child nodes. (See the documentation for Node for
a discussion of the tree representation of a message.)
Many header fields, such as the Date header field, have
structured field bodies. For those header fields, the structured field
body is represented by a subclass of FieldBody. Other
header fields, such as the Content-Description header field, have
unstructured field bodies. For those headers fields, the unstructured
field body is represented by the FieldBody class
itself.
You may call the inherited Node.string() method to get the text of
the field body. Alternatively, you may call the text() to get
the unfolded text of the field body. You may call the inherited Node.setString(ByteString) method to set the text of the field body.
Alternatively, you may call setText(ByteString) to set the text
and the library will fold long lines for you.
Some MIME parsers are broken in that they do not handle the folding
of some fields properly. FieldBody folds its string
representation by default. You may call the method setFoldingEnabled(boolean) to enable or disable folding. To determine if
folding is enabled, call isFoldingEnabled().
| Field Summary | |
|---|---|
protected ByteString |
mText
|
| Fields inherited from class com.hunnysoft.jmime.Node |
|---|
mIsModified, mParent, mString |
| Constructor Summary | |
|---|---|
FieldBody()
Default constructor. |
|
FieldBody(ByteString bstr)
Constructor that takes an initial byte string argument. |
|
FieldBody(FieldBody other)
Copy constructor. |
|
| Method Summary | |
|---|---|
void |
assemble()
Assembles the string representation. |
java.lang.Object |
clone()
Creates a copy of this object. |
static ByteString |
fold(ByteString unfolded,
int offset)
Performs line folding on its argument. |
boolean |
isFoldingEnabled()
Returns true if line folding is enabled. |
protected void |
maybeFold()
Folds the string representation, if line folding is enabled. |
void |
parse()
Parses the string representation. |
void |
setFoldingEnabled(boolean b)
Enables or disables line folding. |
void |
setText(ByteString text)
Sets the unfolded text of the field body. |
ByteString |
text()
Gets the unfolded text of the field body. |
static ByteString |
unfold(ByteString folded)
Performs line unfolding on its argument. |
| 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 |
| Field Detail |
|---|
protected ByteString mText
| Constructor Detail |
|---|
public FieldBody()
This constructor sets the FieldBody object's string
representation to the empty string and sets its parent node to
null.
public FieldBody(FieldBody other)
This constructor performs a deep copy of its argument. The
parent node of the new FieldBody object is set to
null.
other - FieldBody instance to copypublic FieldBody(ByteString bstr)
This constructor sets the FieldBody 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
FieldBody object that has the same value as this
FieldBody object. The parent node of the new
FieldBody object is set to null.
clone in class Nodepublic void parse()
This method, inherited from Node, executes the
parse operation for FieldBody objects. The parse
operation creates or updates the broken-down representation from the
string representation. For FieldBody objects, the
parse operation does nothing, because FieldBody does
not have a broken-down representation. (Subclasses of
FieldBody, however, override this method.)
parse in class NodeNode.assemble()public void assemble()
This method, inherited from Node, executes the
assemble operation for FieldBody objects. The assemble
operation creates or updates the string representation from the
broken-down representation. For FieldBody objects, the
assemble operation does nothing, because FieldBody does
not have a broken-down representation. (Subclasses of
FieldBody, however, override this method.)
assemble in class NodeNode.parse()public ByteString text()
Long lines in Internet mail must be "folded" according to RFC 2822 -- that is, long lines must be wrapped to create several short lines. This method is a convenience method that unfolds the text of the field body before returning it.
public void setText(ByteString text)
Long lines in Internet mail must be "folded" according to RFC 2822 -- that is, long lines must be wrapped to create several short lines. This method is a convenience method that folds the text in its argument and sets the folded text into the field body.
text - unfolded text of the field bodyprotected void maybeFold()
This method may be called from the assemble()
method of subclasses.
public boolean isFoldingEnabled()
true if line folding is enabled.
public void setFoldingEnabled(boolean b)
The default is to enable line folding.
b - true to enable folding
public static ByteString fold(ByteString unfolded,
int offset)
The parameter offset indicates how much space
should be reserved in the first line for the header field name.
unfolded - unfolded stringoffset - amount of space to reserve for the header field name
public static ByteString unfold(ByteString folded)
folded - folded string
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||