nan.model
Class MessageHeader

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

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

A representation of an NNTP message header in RFC 850 format.

Version:
1.12, 1/2/04
Author:
John David Ratliff

Field Summary
static java.lang.String XML_HEADER
          XML tag for header property.
static java.lang.String XML_NAME
          XML tag for header name.
static java.lang.String XML_READ
          XML tag for read property.
static java.lang.String XML_TAG
          XML tag for serialization purposes.
static java.lang.String XML_VALUE
          XML tag for header value.
 
Constructor Summary
MessageHeader()
          Creates a new MessageHeader object.
 
Method Summary
 void addHeader(java.lang.String name, java.lang.String value)
          Adds a header to this MessageHader.
 boolean containsHeader(java.lang.String name)
          Asks if this MessageHeader contains a particular header.
 java.lang.String getHeader(java.lang.String name)
          Gets a message header.
 java.lang.String getHeaders()
          Gets a String list of all the headers.
 java.lang.String getValue(java.lang.String name)
          Gets the value of a header.
 boolean isRead()
          Asks if this message has been read.
 void replaceHeader(java.lang.String name, java.lang.String value)
          Replaces a header.
 void setRead(boolean read)
          Sets if this message has been read.
 java.lang.String toString()
          Returns a String representation of this MessageHeader.
 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_HEADER

public static final java.lang.String XML_HEADER
XML tag for header property.

See Also:
Constant Field Values

XML_NAME

public static final java.lang.String XML_NAME
XML tag for header name.

See Also:
Constant Field Values

XML_VALUE

public static final java.lang.String XML_VALUE
XML tag for header value.

See Also:
Constant Field Values

XML_READ

public static final java.lang.String XML_READ
XML tag for read property.

See Also:
Constant Field Values
Constructor Detail

MessageHeader

public MessageHeader()
Creates a new MessageHeader object.

Method Detail

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Adds a header to this MessageHader. Duplicate headers are ignored. To change a value, use the replaceHeader() method.

Parameters:
name - The name of the header. Case is ignored.
value - The value of the header.

getHeader

public java.lang.String getHeader(java.lang.String name)
                           throws NoSuchHeaderException
Gets a message header.

Parameters:
name - The name of the header. Case is ignored.
Returns:
The retrieved header.
Throws:
NoSuchHeaderException - if the header does not exist.

getValue

public java.lang.String getValue(java.lang.String name)
                          throws NoSuchHeaderException
Gets the value of a header.

Parameters:
name - The name of the header. Case is ignored.
Returns:
The header value.
Throws:
NoSuchHeaderException - if the header does not exist.

replaceHeader

public void replaceHeader(java.lang.String name,
                          java.lang.String value)
                   throws NoSuchHeaderException
Replaces a header.

Parameters:
name - The name of the header. Case is ignored.
value - The value of the header.
Throws:
NoSuchHeaderException - if the header does not exist.

containsHeader

public boolean containsHeader(java.lang.String name)
Asks if this MessageHeader contains a particular header.

Parameters:
name - The name of the header. Case is ignored.
Returns:
true if the header exists; false otherwise.

getHeaders

public java.lang.String getHeaders()
Gets a String list of all the headers.

Returns:
The headers.

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.

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 MessageHeader. Good for JTreeTable display cells.

Returns:
A String representation.