nan.model
Class Message

java.lang.Object
  extended bynan.model.Message
All Implemented Interfaces:
Selected, Transposer, XMLSerializable

public class Message
extends java.lang.Object
implements XMLSerializable, Transposer, Selected

A representation of an NNTP message in RFC 850 format.

Version:
1.9, 1/6/04
Author:
John David Ratliff

Field Summary
static java.lang.String XML_BODY
          XML tag for the body property.
static java.lang.String XML_TAG
          XML tag for serialization purposes.
 
Constructor Summary
Message()
          Creates a new Message object.
Message(MessageHeader header, java.lang.String body)
          Creates a new Message object.
 
Method Summary
 void addAttachment(Attachment attachment)
          Adds an attachment to this Message.
 Attachment getAttachment(int index)
          Gets an Attachment from this message.
 int getAttachmentCount()
          Gets the count of attachments on this message.
 java.lang.String getBody()
          Gets the body of this Message.
 MessageHeader getHeader()
          Gets the header of this Message.
 java.lang.String getQuotedBody()
          Gets the quoted message body for use in replying.
 boolean isRead()
          Asks if this message has been read.
 Attachment removeAttachment(int index)
          Removes an attachment from this Message.
 void setBody(java.lang.String body)
          Sets the body of this Message.
 void setHeader(MessageHeader header)
          Sets the header of this Message.
 void setRead(boolean read)
          Sets if this message has been read.
 java.lang.String toString()
          Returns a String representation of this Message.
 org.dom4j.Document toXML()
          Converts an object into an XML Document.
 void transpose(java.lang.Object object)
          Transposes (copies over) the values of another object of the same type onto this one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_TAG

public static final java.lang.String XML_TAG
XML tag for serialization purposes.

See Also:
Constant Field Values

XML_BODY

public static final java.lang.String XML_BODY
XML tag for the body property.

See Also:
Constant Field Values
Constructor Detail

Message

public Message(MessageHeader header,
               java.lang.String body)
Creates a new Message object.

Parameters:
header - The MessageHeader of this Message.
body - The body of this message.

Message

public Message()
Creates a new Message object.

Method Detail

getQuotedBody

public java.lang.String getQuotedBody()
Gets the quoted message body for use in replying.

Returns:
The quoted message String.

getBody

public java.lang.String getBody()
Gets the body of this Message.

Returns:
The body.

setBody

public void setBody(java.lang.String body)
Sets the body of this Message.

Parameters:
body - The body.

getHeader

public MessageHeader getHeader()
Gets the header of this Message.

Returns:
The MessageHeader.

setHeader

public void setHeader(MessageHeader header)
Sets the header of this Message.

Parameters:
header - The MessageHeader.

isRead

public boolean isRead()
Asks if this message has been read.

Specified by:
isRead in interface Selected
Returns:
true if this message has been read; false otherwise.

setRead

public void setRead(boolean read)
Sets if this message has been read.

Specified by:
setRead in interface Selected
Parameters:
read - true if read; false otherwise.

getAttachmentCount

public int getAttachmentCount()
Gets the count of attachments on this message.

Returns:
The Attachment count.

addAttachment

public void addAttachment(Attachment attachment)
Adds an attachment to this Message.

Parameters:
attachment - The Attachment.

removeAttachment

public Attachment removeAttachment(int index)
                            throws java.lang.IndexOutOfBoundsException
Removes an attachment from this Message.

Parameters:
index - The index of the attachment.
Returns:
The removed Attachment.
Throws:
java.lang.IndexOutOfBoundsException - if index is not valid (0 <= index < size).

getAttachment

public Attachment getAttachment(int index)
                         throws java.lang.IndexOutOfBoundsException
Gets an Attachment from this message.

Parameters:
index - The index number of the Attachment.
Returns:
The Attachment.
Throws:
java.lang.IndexOutOfBoundsException - if the index is invalid (0 < index < getAttachmentCount()).

toXML

public org.dom4j.Document toXML()
Converts an object into an XML Document.

Specified by:
toXML in interface XMLSerializable
Returns:
The XML Document.

transpose

public void transpose(java.lang.Object object)
Transposes (copies over) the values of another object of the same type onto this one. If the object is not the same type as the invoked object, it will be ignored.

Specified by:
transpose in interface Transposer
Parameters:
object - The object to transpose over this one.

toString

public java.lang.String toString()
Returns a String representation of this Message.

Returns:
A String representation.