com.hunnysoft.jmime
Class Field

java.lang.Object
  extended bycom.hunnysoft.jmime.Node
      extended bycom.hunnysoft.jmime.Field
All Implemented Interfaces:
java.lang.Cloneable

public class Field
extends Node

Class that represents a header field.

Field represents a header field as described in RFC 2822. According to RFC 2822, a header field contains a field name and a field body. In Hunny JMIME, a Field contains two elements: a String that contains its field name and a FieldBody object that represents its field body.

In the document tree representation of a message, a Field object is always an intermediate node, having a parent node and a single child node. The parent node is the Headers object that contains it. The child node is the FieldBody object it contains.

To get or set the field name, use the methods fieldName() and setFieldName(String). To get or set the contained FieldBody object, use fieldBody() and setFieldBody(FieldBody).


Field Summary
 
Fields inherited from class com.hunnysoft.jmime.Node
mIsModified, mParent, mString
 
Constructor Summary
Field()
          Default constructor.
Field(ByteString bstr)
          Constructor that takes an initial byte string argument.
Field(Field other)
          Copy constructor.
 
Method Summary
 void assemble()
          Assembles the string representation.
 java.lang.Object clone()
          Creates a copy of this object.
 FieldBody fieldBody()
          Gets the field body.
 java.lang.String fieldName()
          Gets the field name.
static FieldBodyFactory getFieldBodyFactory()
          Gets the FieldBodyFactory instance.
 void parse()
          Parses the string representation.
 void setFieldBody(FieldBody fieldBody)
          Sets the field body.
static void setFieldBodyFactory(FieldBodyFactory factory)
          Sets the FieldBodyFactory instance.
 void setFieldName(java.lang.String name)
          Sets the field name.
 
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

Field

public Field()
Default constructor.

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


Field

public Field(Field other)
Copy constructor.

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

Parameters:
other - Field instance to copy

Field

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

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

clone

public java.lang.Object clone()
Creates a copy of this object.

This method, inherited from Object, creates a new Field object that has the same value as this Field object. The parent node of the new Field object is set to null.

Overrides:
clone in class Node
Returns:
a copy of this object

parse

public void parse()
Parses the string representation.

This method, inherited from Node, executes the parse operation for Field objects. The parse operation creates or updates the broken-down representation from the string representation. For Field objects, the parse operation updates the value of the field name string and creates an instance of the appropriate subclass of FieldBody. This method also calls the parse() method of the FieldBody object it creates.

You should call this method after you set or modify the string representation, and before you access the field name or field 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 Field objects. The assemble operation creates or updates the string representation from the broken-down representation. For Field objects, the assemble operation builds the string representation from the field name and the string representation of the contained FieldBody object. Before it builds the string representation, this method calls the assemble() method of its contained FieldBody object.

You should call this method after you set or modify either the field name or the contained FieldBody object, and before you retrieve the string representation.

This method clears the is-modified flag.

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

fieldName

public final java.lang.String fieldName()
Gets the field name.

Returns:
field name

setFieldName

public final void setFieldName(java.lang.String name)
Sets the field name.

Parameters:
name - field name

fieldBody

public final FieldBody fieldBody()
Gets the field body.

Returns:
contained FieldBody

setFieldBody

public final void setFieldBody(FieldBody fieldBody)
Sets the field body.

Parameters:
fieldBody - field body object

getFieldBodyFactory

public static FieldBodyFactory getFieldBodyFactory()
Gets the FieldBodyFactory instance.

The library uses a single FieldBodyFactory instance to create new FieldBody objects. Developers may create subclasses of library classes. The library uses the factory installed by the developer to create instances of these subclasses.

Returns:
the FieldBodyFactory instance

setFieldBodyFactory

public static void setFieldBodyFactory(FieldBodyFactory factory)
Sets the FieldBodyFactory instance.

The library uses a single FieldBodyFactory instance to create new FieldBody objects. Developers may create subclasses of library classes. The library uses the factory installed by the developer to create instances of these subclasses.

Parameters:
factory - the FieldBodyFactory instance