javax.mail.internet

Class InternetHeaders

public class InternetHeaders extends 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
voidaddHeader(String name, String value)
Add a new value to the header with the supplied name.
voidaddHeaderLine(String line)
EnumerationgetAllHeaderLines()
EnumerationgetAllHeaders()
Return all headers.
String[]getHeader(String name)
Return all the values for the specified header.
StringgetHeader(String name, String delimiter)
Return the values for the specified header as a single String.
EnumerationgetMatchingHeaderLines(String[] names)
EnumerationgetMatchingHeaders(String[] names)
EnumerationgetNonMatchingHeaderLines(String[] names)
EnumerationgetNonMatchingHeaders(String[] names)
voidload(InputStream in)
Read and parse the supplied stream and add all headers to the current set.
voidremoveHeader(String name)
Remove all header entries with the supplied name
voidsetHeader(String name, String value)
Set the value of the header to the supplied value; any existing headers are removed.

Constructor Detail

InternetHeaders

public InternetHeaders()
Create an empty InternetHeaders

InternetHeaders

public InternetHeaders(InputStream in)
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

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)
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