javax.mail.internet
Class InternetHeaders

java.lang.Object
  extended by javax.mail.internet.InternetHeaders

public class InternetHeaders
extends Object

Class that represents the RFC822 headers associated with a message.

Version:
$Rev: 702234 $ $Date: 2008-10-06 15:25:41 -0400 (Mon, 06 Oct 2008) $

Nested Class Summary
protected static class InternetHeaders.InternetHeader
           
 
Field Summary
protected  List headers
           
 
Constructor Summary
InternetHeaders()
          Create an empty InternetHeaders
InternetHeaders(InputStream in)
          Create a new InternetHeaders initialized by reading headers from the stream.
 
Method Summary
 void addHeader(String name, String value)
          Add a new value to the header with the supplied name.
 void addHeaderLine(String line)
          Add an RFC822 header line to the header store.
 Enumeration getAllHeaderLines()
          Return all the header lines as an Enumeration of Strings.
 Enumeration getAllHeaders()
          Return all headers.
 String[] getHeader(String name)
          Return all the values for the specified header.
 String getHeader(String name, String delimiter)
          Return the values for the specified header as a single String.
 Enumeration getMatchingHeaderLines(String[] names)
          Return all matching header lines as an Enumeration of Strings.
 Enumeration getMatchingHeaders(String[] names)
          Return all matching Header objects.
 Enumeration getNonMatchingHeaderLines(String[] names)
          Return all non-matching header lines.
 Enumeration getNonMatchingHeaders(String[] names)
          Return all non matching Header objects.
 void load(InputStream in)
          Read and parse the supplied stream and add all headers to the current set.
 void removeHeader(String name)
          Remove all header entries with the supplied name
 void setHeader(String name, String value)
          Set the value of the header to the supplied value; any existing headers are removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headers

protected List headers
Constructor Detail

InternetHeaders

public InternetHeaders()
Create an empty InternetHeaders


InternetHeaders

public InternetHeaders(InputStream in)
                throws MessagingException
Create a new InternetHeaders initialized by reading headers from the stream.

Parameters:
in - the RFC822 input stream to load from
Throws:
MessagingException - if there is a problem pasring the stream
Method Detail

load

public void load(InputStream in)
          throws MessagingException
Read and parse the supplied stream and add all headers to the current set.

Parameters:
in - the RFC822 input stream to load from
Throws:
MessagingException - if there is a problem pasring the stream

getHeader

public String[] getHeader(String name)
Return all the values for the specified header.

Parameters:
name - the header to return
Returns:
the values for that header, or null if the header is not present

getHeader

public String getHeader(String name,
                        String delimiter)
Return the values for the specified header as a single String. If the header has more than one value then all values are concatenated together separated by the supplied delimiter.

Parameters:
name - the header to return
delimiter - the delimiter used in concatenation
Returns:
the header as a single String

setHeader

public void setHeader(String name,
                      String value)
Set the value of the header to the supplied value; any existing headers are removed.

Parameters:
name - the name of the header
value - the new value

addHeader

public void addHeader(String name,
                      String value)
Add a new value to the header with the supplied name.

Parameters:
name - the name of the header to add a new value for
value - another value

removeHeader

public void removeHeader(String name)
Remove all header entries with the supplied name

Parameters:
name - the header to remove

getAllHeaders

public Enumeration getAllHeaders()
Return all headers.

Returns:
an Enumeration
containing all headers

getMatchingHeaders

public Enumeration getMatchingHeaders(String[] names)
Return all matching Header objects.


getNonMatchingHeaders

public Enumeration getNonMatchingHeaders(String[] names)
Return all non matching Header objects.


addHeaderLine

public void addHeaderLine(String line)
Add an RFC822 header line to the header store. If the line starts with a space or tab (a continuation line), add it to the last header line in the list. Otherwise, append the new header line to the list. Note that RFC822 headers can only contain US-ASCII characters

Parameters:
line - raw RFC822 header line

getAllHeaderLines

public Enumeration getAllHeaderLines()
Return all the header lines as an Enumeration of Strings.


getMatchingHeaderLines

public Enumeration getMatchingHeaderLines(String[] names)
Return all matching header lines as an Enumeration of Strings.


getNonMatchingHeaderLines

public Enumeration getNonMatchingHeaderLines(String[] names)
Return all non-matching header lines.



Copyright © 2003-2009 The Apache Software Foundation. All Rights Reserved.