com.hunnysoft.jmime
Class Node

java.lang.Object
  extended bycom.hunnysoft.jmime.Node
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Body, EncodedWord, Entity, Field, FieldBody, Headers, Parameter

public abstract class Node
extends java.lang.Object
implements java.lang.Cloneable

Abstract base class for all classes representing message components.

Node is the root of an inheritance hierarchy that includes many classes in Hunny JMIME. All classes that represent MIME document components are subclasses of Node. The Node class defines important features that are inherited by these subclasses. These features are the following:


Field Summary
protected  boolean mIsModified
          Is-modified flag.
protected  Node mParent
          Parent node.
protected  ByteString mString
          String representation.
 
Constructor Summary
Node()
          Default constructor.
Node(ByteString bstr)
          Constructor that takes an initial byte string argument.
Node(Node other)
          Copy constructor.
 
Method Summary
 void _setString(ByteString bstr)
          Sets the string representation.
abstract  void assemble()
          Assembles the string representation.
 java.lang.Object clone()
          Throws UnsupportedOperationException.
 boolean isModified()
          Returns true if the is-modified flag is set.
 Node parent()
          Gets the parent node.
abstract  void parse()
          Parses the string representation.
 void setModified()
          Sets the is-modified flag and requests the parent node to set its is-modified flag.
 void setParent(Node parent)
          Sets the parent node.
 void setString(ByteString bstr)
          Sets the string representation.
 ByteString string()
          Gets the string representation.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mString

protected ByteString mString
String representation.


mParent

protected Node mParent
Parent node.


mIsModified

protected boolean mIsModified
Is-modified flag.

Constructor Detail

Node

public Node()
Default constructor.

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


Node

public Node(Node other)
Copy constructor.

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

Parameters:
other - Node instance to copy

Node

public Node(ByteString bstr)
Constructor that takes an initial byte string argument.

This constructor sets the Node object's string representation to bstr. 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

clone

public java.lang.Object clone()
Throws UnsupportedOperationException.

Subclasses of Node override this function to return a copy of the object. Because Node is an abstract class, this method throws an UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException

parse

public abstract void parse()
Parses the string representation.

This method executes the parse operation. The parse operation creates or updates the broken-down representation from the string representation. The parse operation is the opposite of the assemble operation. In some derived classes, such as Headers, the parse operation also creates the child nodes of the object. (In the case of Headers, the child nodes are Field objects that represent the header fields contained in the headers.) The parse() method calls the parse() method of all of the child nodes.

This function clears the is-modified flag.

See Also:
assemble()

assemble

public abstract void assemble()
Assembles the string representation.

This method executes the assemble operation. The assemble operation creates or updates the string representation from the broken-down representation. The assemble operation is the opposite of the parse operation. Before creating or updating the string representation, the assemble operation invokes the assemble operation of each of its child nodes. If the is-modifed flag for a Node is cleared, the assemble() method will return immediately without calling the assemble() method of any of its child nodes, and without updating the string representation.

This function clears the is-modified flag.

See Also:
parse()

string

public final ByteString string()
Gets the string representation.

If the broken-down representation and the string representation are not consistent, you should call the assemble() method before you call string(), so that the string representation will be updated first.

Returns:
the string representation
See Also:
assemble()

setString

public final void setString(ByteString bstr)
Sets the string representation.

Normally, you call the parse() method immediately after this function to update the broken-down representation.

Parameters:
bstr - new value for the string representation
See Also:
parse()

_setString

public final void _setString(ByteString bstr)
Sets the string representation.

This is an advanced method that the library itself uses. It is public so that developers may extend the library. Unlike setString(), this function does not set the is-modified flag of the parent node.

Parameters:
bstr - new value for the string representation
See Also:
setString(com.hunnysoft.jmime.ByteString)

parent

public final Node parent()
Gets the parent node.

Returns:
the parent node

setParent

public final void setParent(Node parent)
Sets the parent node.

Parameters:
parent - the parent node

isModified

public final boolean isModified()
Returns true if the is-modified flag is set.

Returns:
true if the is-modified flag is set

setModified

public final void setModified()
Sets the is-modified flag and requests the parent node to set its is-modified flag.


toString

public java.lang.String toString()