com.hunnysoft.jmime
Class MsgId

java.lang.Object
  extended by com.hunnysoft.jmime.Node
      extended by com.hunnysoft.jmime.FieldBody
          extended by com.hunnysoft.jmime.MsgId
All Implemented Interfaces:
java.lang.Cloneable

public class MsgId
extends FieldBody

Class that represents an RFC 2822 message ID.

MsgId represents a message ID as described in RFC 2822. A message ID appears as the field body of the "Message-ID" header field, and has a local part and a domain separated by an "at" sign. The following is an example of a "Message-ID" header field:

    Message-ID: <994590483.5890@somehost.net>

In the above example, the local part is "994590483.5890" and the domain is "somehost.net". In MIME body parts, a message ID can also appear as the field body of the "Content-ID" header field.

In Hunny JMIME, a MsgId contains strings that contain the local part and the domain.

In the document tree representation of message, a MsgId object may only be a leaf node, having a parent but no child nodes.

MsgId has methods for getting or setting its local part and its domain. You may have the library to create the contents of a MsgId object for you by calling the methods createLocalPart() and createDomain(). You can set the default domain by calling the static method setDefaultDomain(String).


Field Summary
 
Fields inherited from class com.hunnysoft.jmime.FieldBody
mText
 
Fields inherited from class com.hunnysoft.jmime.Node
mIsModified, mParent, mString
 
Constructor Summary
MsgId()
          Default constructor.
MsgId(ByteString bstr)
          Constructor that takes an initial byte string argument.
MsgId(MsgId other)
          Copy constructor.
 
Method Summary
 void assemble()
          Assembles the string representation.
 java.lang.Object clone()
          Creates a copy of this object.
 void createDefault()
          Creates the local part and domain.
 void createDomain()
          Creates the domain.
 void createLocalPart()
          Creates the local part.
 java.lang.String domain()
          Gets the domain.
 java.lang.String localPart()
          Gets the local part.
 void parse()
          Parses the string representation.
static void setDefaultDomain(java.lang.String domain)
          Sets the default domain.
 void setDomain(java.lang.String domain)
          Sets the domain.
 void setLocalPart(java.lang.String localPart)
          Sets the local part.
 
Methods inherited from class com.hunnysoft.jmime.FieldBody
fold, isFoldingEnabled, maybeFold, setFoldingEnabled, setText, text, unfold
 
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

MsgId

public MsgId()
Default constructor.

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


MsgId

public MsgId(MsgId other)
Copy constructor.

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

Parameters:
other - MsgId instance to copy

MsgId

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

This constructor sets the MsgId 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 MsgId object that has the same value as this MsgId object. The parent node of the new MsgId object is set to null.

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

parse

public void parse()
Parses the string representation.

This method, inherited from Node, executes the parse operation for MsgId objects. The parse method creates or updates the broken-down representation from the string representation. For MsgId objects, the parse method parses the string representation to extract the local part and domain attributes.

You should call this method after you set or modify the string representation, and before you retrieve the local part or domain.

This method clears the is-modified flag.

Overrides:
parse in class FieldBody
See Also:
Node.assemble()

assemble

public void assemble()
Assembles the string representation.

This method, inherited from Node, executes the assemble operation for MsgId objects. The assemble method creates or updates the string representation from the broken-down representation. For MsgId objects, the assemble method builds the string representation from the local part and domain.

You should call this method after you set or modify the local part or domain of this MsgId object, and before you retrieve the string representation.

This method clears the is-modified flag.

Overrides:
assemble in class FieldBody
See Also:
Node.parse()

localPart

public java.lang.String localPart()
Gets the local part.

Returns:
local part

setLocalPart

public void setLocalPart(java.lang.String localPart)
Sets the local part.

Parameters:
localPart - local part

domain

public java.lang.String domain()
Gets the domain.

Returns:
domain

setDomain

public void setDomain(java.lang.String domain)
Sets the domain.

Parameters:
domain - domain

createDefault

public void createDefault()
Creates the local part and domain.

This convenience method calls createLocalPart(), createDomain(), and assemble().


createLocalPart

public void createLocalPart()
Creates the local part.

The created local part is unique to the local machine. The method creates the local part using the current time and a thread-synchronized counter.


createDomain

public void createDomain()
Creates the domain.

If a default domain is set, then that domain is used. Otherwise, this method queries the operating system to get the fully-qualified domain name.

See Also:
setDefaultDomain(java.lang.String)

setDefaultDomain

public static void setDefaultDomain(java.lang.String domain)
Sets the default domain.

The method createDomain() uses the value set by this static method. If you set the value to null, then createDomain() queries the operating system for the fully-qualified domain name.

See Also:
createDomain()