com.hunnysoft.jmime
Class Entity

java.lang.Object
  extended bycom.hunnysoft.jmime.Node
      extended bycom.hunnysoft.jmime.Entity
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BodyPart, Message

public abstract class Entity
extends Node

Abstract class that represents a MIME entity.

RFC 2045 defines an entity as either a message or a body part, both of which have a collection of header fields and a body. In Hunny JMIME, an entity is represented by the class Entity, which contains both a Headers object and a Body object.

In the document tree representation of message, an Entity object may be either a root node, having child nodes but no parent node, or an intermediate node, having both a parent node and child nodes. An Entity object that is a root node should be a Message object. An Entity object that is an intermediate node should be a BodyPart object, and its parent should be a Body object. The child nodes of an Entity object are the Headers and Body objects it contains. (See the documentation for Node for a discussion of the tree representation of a message.)

Since Entity is an abstract base class, you cannot create instances of it directly. Entity has two derived classes, Message and BodyPart, which are concrete classes.

To access the contained Headers object, call the headers() method. To access the contained Body object, call the body() method.


Field Summary
 
Fields inherited from class com.hunnysoft.jmime.Node
mIsModified, mParent, mString
 
Constructor Summary
protected Entity()
          Default constructor.
protected Entity(ByteString bstr)
          Constructor that takes an initial byte string argument.
  Entity(Entity other)
          Copy constructor.
 
Method Summary
 void assemble()
          Assembles the string representation.
 Body body()
          Gets the contained body.
 Headers headers()
          Gets the contained header fields.
 void parse()
          Parses the string representation.
 void setBody(Body body)
          Sets the contained body.
 void setHeaders(Headers headers)
          Sets the contained header fields.
 
Methods inherited from class com.hunnysoft.jmime.Node
_setString, clone, 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

Entity

protected Entity()
Default constructor.

This constructor sets the Entity object's string representation to the empty string and sets its parent node to null.


Entity

public Entity(Entity other)
Copy constructor.

This constructor performs a deep copy of its argument. The parent node of the new Entity object is set to null.

Parameters:
other - Entity instance to copy

Entity

protected Entity(ByteString bstr)
Constructor that takes an initial byte string argument.

This constructor sets the Entity 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.

Parameters:
bstr - initial value for the string representation
Method Detail

parse

public void parse()
Parses the string representation.

This method, inherited from Node, executes the parse operation for Entity objects. The parse operation creates or updates the broken-down representation from the string representation. For Entity objects, the parse method parses the string representation and sets the values of the Headers and Body objects it contains. This method also calls the parse() methods of the contained Headers and Body objects.

You should call this method after you set or modify the string representation, and before you access either the contained headers or body.

This method clears the is-modified flag.

Specified by:
parse in class Node
See Also:
Node.assemble()

assemble

public void assemble()
Assembles the string representation.

This method, inherited from Node, executes the assemble operation for Entity objects. The assemble operation creates or updates the string representation from the broken-down representation. For Entity objects, the assemble method builds the string representation from the string representations of the contained Headers and Body objects. This method calls the assemble() methods of its Headers and Body objects.

You should call this method after you modify either the contained headers or body, and before you retrieve the string representation.

This method clears the is-modified flag.

Specified by:
assemble in class Node
See Also:
Node.parse()

headers

public Headers headers()
Gets the contained header fields.


setHeaders

public void setHeaders(Headers headers)
Sets the contained header fields.


body

public Body body()
Gets the contained body.


setBody

public void setBody(Body body)
Sets the contained body.