javax.mail.internet

Class InternetHeaders


public class InternetHeaders
extends java.lang.Object

Class that represents the RFC822 headers associated with a message.

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)
Enumeration
getAllHeaderLines()
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)
Enumeration
getMatchingHeaders(String[] names)
Enumeration
getNonMatchingHeaderLines(String[] names)
Enumeration
getNonMatchingHeaders(String[] names)
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.

Constructor Details

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 Details

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

addHeaderLine

public void addHeaderLine(String line)

getAllHeaderLines

public Enumeration getAllHeaderLines()

getAllHeaders

public Enumeration getAllHeaders()
Return all headers.
Returns:
an Enumeration
containing all headers

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

getMatchingHeaderLines

public Enumeration getMatchingHeaderLines(String[] names)

getMatchingHeaders

public Enumeration getMatchingHeaders(String[] names)

getNonMatchingHeaderLines

public Enumeration getNonMatchingHeaderLines(String[] names)

getNonMatchingHeaders

public Enumeration getNonMatchingHeaders(String[] names)

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

removeHeader

public void removeHeader(String name)
Remove all header entries with the supplied name
Parameters:
name - the header to remove

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