org.apache.servlet.mail
Class MailHeaders

java.lang.Object
  |
  +--org.apache.servlet.mail.MailHeaders

public abstract class MailHeaders
extends java.lang.Object
implements java.io.Serializable

This interface defines a container for mail headers. Each header must use MIME format:

name: value
.

Version:
pre-draft 1.0 (submitted for review)
Author:
Stefano Mazzocchi , Pierpaolo Fumagalli
See Also:
Serialized Form

Constructor Summary
MailHeaders()
           
 
Method Summary
 java.util.Date getDate()
          Returns the date associated with the mail message using standard date format.
 java.util.Date getDate(java.lang.String format)
          Returns the date associated with the mail message using given date format.
abstract  java.lang.String getHeader(java.lang.String name)
          Get the header value associated with the given name.
abstract  java.util.Enumeration getHeaderNames()
          Returns the list of all header names.
abstract  java.lang.String[] getHeaderValues(java.lang.String name)
          Get the header values associated with the given name.
 MailAddress getReplyTo()
          Returns the mail address associated to the reply-to field.
 java.lang.String getSubject()
          Returns the subject of the mail message.
 void removeHeader(java.lang.String name)
          Removes all headers associated with the specified name.
abstract  void removeHeader(java.lang.String name, java.lang.String value)
          Removes the header with specified name and value.
 void setDate(java.util.Date date)
          Sets the date using standard date format.
 void setDate(java.util.Date date, java.lang.String format)
          Sets the date using given date format.
 void setHeader(java.lang.String name, java.lang.String value)
          Sets the value of the header specified by name.
abstract  void setHeader(java.lang.String name, java.lang.String value, boolean overwrite)
          Sets the value of the header specified by name.
 void setReplyTo(MailAddress replyto)
          Sets the mail address that should be used as the reply address.
 void setSubject(java.lang.String subject)
          Sets the subject of the mail message.
 java.lang.String toString()
          Creates a string representation of this container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MailHeaders

public MailHeaders()
Method Detail

getHeader

public abstract java.lang.String getHeader(java.lang.String name)
Get the header value associated with the given name. If multiple values are found the first one is returned. If header is not found null is returned.

getHeaderValues

public abstract java.lang.String[] getHeaderValues(java.lang.String name)
Get the header values associated with the given name. If header is not found null is returned.

getHeaderNames

public abstract java.util.Enumeration getHeaderNames()
Returns the list of all header names.

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Sets the value of the header specified by name. If name is already in use, another header with the same name is created.

setHeader

public abstract void setHeader(java.lang.String name,
                               java.lang.String value,
                               boolean overwrite)
Sets the value of the header specified by name. If name is already in use, another header with the same name is created.

removeHeader

public void removeHeader(java.lang.String name)
Removes all headers associated with the specified name.

removeHeader

public abstract void removeHeader(java.lang.String name,
                                  java.lang.String value)
Removes the header with specified name and value. If value is null all headers matching the specified name are removed.

toString

public java.lang.String toString()
Creates a string representation of this container. Each header must be formatted as in MIME specification.
Overrides:
toString in class java.lang.Object

getDate

public java.util.Date getDate()
                       throws java.text.ParseException
Returns the date associated with the mail message using standard date format.

getDate

public java.util.Date getDate(java.lang.String format)
                       throws java.text.ParseException
Returns the date associated with the mail message using given date format.

setDate

public void setDate(java.util.Date date)
Sets the date using standard date format.

setDate

public void setDate(java.util.Date date,
                    java.lang.String format)
Sets the date using given date format.

getReplyTo

public MailAddress getReplyTo()
Returns the mail address associated to the reply-to field.

setReplyTo

public void setReplyTo(MailAddress replyto)
Sets the mail address that should be used as the reply address.

getSubject

public java.lang.String getSubject()
Returns the subject of the mail message.

setSubject

public void setSubject(java.lang.String subject)
Sets the subject of the mail message.