com.cometway.email
Class Message

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.email.Message
All Implemented Interfaces:
IMessage, java.io.Serializable

public class Message
extends Props
implements IMessage, java.io.Serializable

Message is an IMessage that represents an RFC822 compliant message. A Message is required to have at least the 'To' and 'From' headers (though these headers may be empty)

See Also:
Serialized Form

Field Summary
static java.lang.String HEADER_NOT_FOUND
           
 
Constructor Summary
Message()
          A constructor for creating an empty Message with empty 'To' and 'From' fields
Message(java.lang.String entireMessage)
          A constructor for creating a Message from a String
Message(java.lang.String headerInfo, java.lang.String message)
          A constructor for creating a Message with the specified headers and message body
Message(java.lang.String from, java.lang.String to, java.lang.String message)
          A constructor for creating a Message with the specified 'To' and 'From' fields and message body
 
Method Summary
 java.lang.String getHeaderInfo(java.lang.String key)
          Given a key, method returns the value of the header referenced by key if any
 java.util.Enumeration getHeaders()
          Method yields an Enumeration of header keys for this Message
 java.lang.String getMessage()
          getMessage returns the message body of this Message
 void removeAllHeaders()
          removeAllHeaders removes all headers from this Message
 void setHeaderInfo(java.lang.String key, java.lang.String info)
          setHeaderInfo sets the value of a specified header for this Message, adding the header if necessary
 void setMessage(java.lang.String s)
          setMessage sets the value of the message body for this Message
 java.lang.String toString()
          Method yields the String representation of this Message
 
Methods inherited from class com.cometway.props.Props
addListener, append, copy, copyFrom, copyTo, decrementInteger, dump, enableListeners, enumerateKeys, format, getBoolean, getByteArray, getCharacter, getDate, getDate, getDateString, getDouble, getFloat, getHexString, getInteger, getKeys, getLong, getNextKey, getProperty, getProperty, getPropsContainer, getSize, getString, getString, getTokens, getTokens, getTrimmedString, getVector, hasProperty, incrementInteger, insertProps, loadProps, notifyPropsChanged, notifyPropsChangedIgnore, notifyPropsChangedIgnore, parse, propertyMatchesRegEx, readFromFile, regExPropertyMatches, removeAll, removeListener, removeProperty, resumeNotify, saveProps, set, setBoolean, setCharacter, setDefault, setDouble, setFloat, setInteger, setLong, setProperty, setProperty, setProperty, setPropsContainer, suspendNotify, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEADER_NOT_FOUND

public static final java.lang.String HEADER_NOT_FOUND
See Also:
Constant Field Values
Constructor Detail

Message

public Message()
A constructor for creating an empty Message with empty 'To' and 'From' fields


Message

public Message(java.lang.String entireMessage)
A constructor for creating a Message from a String

Parameters:
entireMessage - A String representing the message body and headers for this Message

Message

public Message(java.lang.String from,
               java.lang.String to,
               java.lang.String message)
A constructor for creating a Message with the specified 'To' and 'From' fields and message body

Parameters:
from - A String that will be the value of the 'From' header for this Message
to - A String that will be the value of the 'To' header for this Message
message - A String that will be the value of the message body for this Message

Message

public Message(java.lang.String headerInfo,
               java.lang.String message)
A constructor for creating a Message with the specified headers and message body

Parameters:
headerInfo - A String representing the headers for this Message
message - A String that will be the value of the message body for this Message
Method Detail

getHeaderInfo

public java.lang.String getHeaderInfo(java.lang.String key)
Given a key, method returns the value of the header referenced by key if any

Specified by:
getHeaderInfo in interface IMessage
Parameters:
key - the header name to be extracted

getHeaders

public java.util.Enumeration getHeaders()
Method yields an Enumeration of header keys for this Message

Specified by:
getHeaders in interface IMessage

getMessage

public java.lang.String getMessage()
getMessage returns the message body of this Message

Specified by:
getMessage in interface IMessage

removeAllHeaders

public void removeAllHeaders()
removeAllHeaders removes all headers from this Message

Specified by:
removeAllHeaders in interface IMessage

setHeaderInfo

public void setHeaderInfo(java.lang.String key,
                          java.lang.String info)
setHeaderInfo sets the value of a specified header for this Message, adding the header if necessary

Specified by:
setHeaderInfo in interface IMessage
Parameters:
key - the header name to be set
info - the header value

setMessage

public void setMessage(java.lang.String s)
setMessage sets the value of the message body for this Message

Specified by:
setMessage in interface IMessage
Parameters:
s - the new message body

toString

public java.lang.String toString()
Method yields the String representation of this Message

Specified by:
toString in interface IMessage
Overrides:
toString in class Props