javax.mail.internet
Class InternetHeaders
java.lang.Object
javax.mail.internet.InternetHeaders
public class InternetHeaders
extends java.lang.Object
A collection of RFC 822 headers.
The string representation of RFC822 and MIME header fields must contain
only US-ASCII characters. Non US-ASCII characters must be encoded as per
the rules in RFC 2047. This class does not enforce those rules; the
caller is expected to use
MimeUtility
to ensure that header
values are correctly encoded.
protected List | headers - The list of headers.
|
void | addHeader(String name, String value) - Adds the specified header.
|
void | addHeaderLine(String line) - Adds an RFC 822 header-line to this InternetHeaders.
|
Enumeration | getAllHeaderLines() - Returns all the header-lines.
|
Enumeration | getAllHeaders() - Returns all the headers.
|
String[] | getHeader(String name) - Returns all the values for the specified header.
|
String | getHeader(String name, String delimiter) - Returns all the headers for this header name as a single string,
with headers separated by the given delimiter.
|
Enumeration | getMatchingHeaderLines(String[] names) - Returns all the header-lines with any of the given names.
|
Enumeration | getMatchingHeaders(String[] names) - Returns all the headers with any of the given names.
|
Enumeration | getNonMatchingHeaderLines(String[] names) - Returns all the header-lines without any of the given names.
|
Enumeration | getNonMatchingHeaders(String[] names) - Returns all the headers without any of the given names.
|
void | load(InputStream is) - Parses the specified RFC 822 message stream, storing the headers in
this InternetHeaders.
|
void | removeHeader(String name) - Removes all headers matching the given name.
|
void | setHeader(String name, String value) - Sets the specified header.
|
headers
protected List headers
The list of headers.
InternetHeaders
public InternetHeaders()
Constructor for an empty InternetHeaders.
InternetHeaders
public InternetHeaders(InputStream is)
throws MessagingException
Constructor with an RFC 822 message stream.
The stream is parsed up to the blank line separating the headers from
the body, and is left positioned at the start of the body.
is
- an RFC 822 input stream
addHeader
public void addHeader(String name,
String value)
Adds the specified header.
name
- the header namevalue
- the header value
addHeaderLine
public void addHeaderLine(String line)
Adds an RFC 822 header-line to this InternetHeaders.
If the line starts with a space or tab (a continuation line for a
folded header), adds it to the last header line in the list.
line
- the raw RFC 822 header-line
getAllHeaderLines
public Enumeration getAllHeaderLines()
Returns all the header-lines.
- an Enumeration of Strings
getAllHeaders
public Enumeration getAllHeaders()
Returns all the headers.
- an Enumeration of Header objects
getHeader
public String[] getHeader(String name)
Returns all the values for the specified header.
getHeader
public String getHeader(String name,
String delimiter)
Returns all the headers for this header name as a single string,
with headers separated by the given delimiter.
If the delimiter is null
, only the first header is returned.
name
- the header namedelimiter
- the delimiter
getMatchingHeaderLines
public Enumeration getMatchingHeaderLines(String[] names)
Returns all the header-lines with any of the given names.
- an Enumeration of Strings
getMatchingHeaders
public Enumeration getMatchingHeaders(String[] names)
Returns all the headers with any of the given names.
names
- the names to match
- an Enumeration of Header objects
getNonMatchingHeaderLines
public Enumeration getNonMatchingHeaderLines(String[] names)
Returns all the header-lines without any of the given names.
- an Enumeration of Strings
getNonMatchingHeaders
public Enumeration getNonMatchingHeaders(String[] names)
Returns all the headers without any of the given names.
names
- the names not to match
- an Enumeration of Header objects
load
public void load(InputStream is)
throws MessagingException
Parses the specified RFC 822 message stream, storing the headers in
this InternetHeaders.
The stream is parsed up to the blank line separating the headers from
the body, and is left positioned at the start of the body.
Note that the headers are added into this InternetHeaders object:
any existing headers in this object are not affected.
is
- an RFC 822 input stream
removeHeader
public void removeHeader(String name)
Removes all headers matching the given name.
setHeader
public void setHeader(String name,
String value)
Sets the specified header.
If existing header lines match the given name, they are all replaced by
the specified value.
name
- the header namevalue
- the header value
© Copyright 2003, 2004
The Free Software Foundation, All rights reserved