java.lang.Object | +--javax.mail.internet.InternetHeaders
Create an empty InternetHeaders object. |
InternetHeaders(InputStream is) Read and parse the given rfc822 message stream till the blank line separating the header from the body. |
void | addHeader(String name, String value) Add a header with the specified name and value to the header list. |
void | addHeaderLine(String line) Add an RFC822 header line to the header store. |
Enumeration | Return all the header lines as an Enumeration of Strings. |
Enumeration | Return all the headers as an Enumeration of Header objects |
String[] | getHeader(String name) Return all the values for the specified header. |
String | getHeader(String name, String delimiter) Get all the headers for this header name, returned as a single String, with headers separated by the delimiter. |
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 is) Read and parse the given rfc822 message stream till the blank line separating the header from the body. |
void | removeHeader(String name) Remove all header entries that match the given name |
void | setHeader(String name, String value) Change the first header line that matches name to have value, adding a new header if no existing header matches. |
public InternetHeaders()
public InternetHeaders(InputStream is)
public void addHeader(String name, String value)
public void addHeaderLine(String line)
public Enumeration getAllHeaderLines()
public Enumeration getAllHeaders()
public String[] getHeader(String name)
public String getHeader(String name, String delimiter)
public Enumeration getMatchingHeaderLines(String[] names)
public Enumeration getMatchingHeaders(String[] names)
public Enumeration getNonMatchingHeaderLines(String[] names)
public Enumeration getNonMatchingHeaders(String[] names)
public void load(InputStream is)
public void removeHeader(String name)
public void setHeader(String name, String value)
name
to have
value
, adding a new header if no existing header matches.
Remove all matching headers but the first.
Note that RFC822 headers can only contain US-ASCII characters
A note on RFC822 and MIME headers RFC822 and MIME header fields must contain only US-ASCII characters. If a header contains non US-ASCII characters, it must be encoded as per the rules in RFC 2047. The MimeUtility class provided in this package can be used to to achieve this. Callers of the
setHeader
,addHeader
, andaddHeaderLine
methods are responsible for enforcing the MIME requirements for the specified headers. In addition, these header fields must be folded (wrapped) before being sent if they exceed the line length limitation for the transport (1000 bytes for SMTP). Received headers may have been folded. The application is responsible for folding and unfolding headers as appropriate.