javax.mail.Header objects. This class is mostly intended for service providers. MimeMessage and MimeBody use this class for holding their 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, and
addHeaderLine 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.
The current implementation supports the System property
mail.mime.ignorewhitespacelines, which if set to true
will cause a line containing only whitespace to be considered
a blank line terminating the header.
javax.mail.internet.MimeUtility
| Modifier and Type | Class and Description |
|---|---|
| protected static class | InternetHeaders.InternetHeader
An individual internet header. |
| pack-priv static class | |
| pack-priv static class | |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| protected List | headers
The actual list of Headers, including placeholder entries. |
| private static final boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | InternetHeaders(InputStream
RFC822 input stream is)Read and parse the given RFC822 message stream till the blank line separating the header from the body. |
| public | InternetHeaders(InputStream
RFC822 input stream is, boolean if UTF-8 encoded headers are allowed allowutf8)Read and parse the given RFC822 message stream till the blank line separating the header from the body. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public Enumeration | Returns: Enumeration of Strings of all header linesReturn all the header lines as an Enumeration of Strings. |
| public Enumeration | Returns: Enumeration of Header objectsReturn all the headers as an Enumeration of
|
| public String[] | |
| public String | |
| public Enumeration | Returns: Enumeration of Strings of all matching header linesthe headers to return names)Return all matching header lines as an Enumeration of Strings. |
| public Enumeration | Returns: Enumeration of matching Header objectsthe headers to return names)Return all matching |
| public Enumeration | Returns: Enumeration of Strings of all non-matching header linesthe headers to not return names)Return all non-matching header lines |
| public Enumeration | Returns: Enumeration of non-matching Header objectsthe headers to not return names)Return all non-matching |
| private static final boolean | |
| public void | load(InputStream
RFC822 input stream is)Read and parse the given RFC822 message stream till the blank line separating the header from the body. |
| public void | load(InputStream
RFC822 input stream is, boolean if UTF-8 encoded headers are allowed allowutf8)Read and parse the given RFC822 message stream till the blank line separating the header from the body. |
| public void | |
| public void |
| headers | back to summary |
|---|---|
| protected List<InternetHeaders. The actual list of Headers, including placeholder entries.
Placeholder entries are Headers with a null value and
are never seen by clients of the InternetHeaders class.
Placeholder entries are used to keep track of the preferred
order of headers. Headers are never actually removed from
the list, they're converted into placeholder entries.
New headers are added after existing headers of the same name
(or before in the case of
| |
| ignoreWhitespaceLines | back to summary |
|---|---|
| private static final boolean ignoreWhitespaceLines | |
| InternetHeaders | back to summary |
|---|---|
| public InternetHeaders() Create an empty InternetHeaders object. Placeholder entries are inserted to indicate the preferred order of headers. | |
| InternetHeaders | back to summary |
|---|---|
| public InternetHeaders(InputStream is) throws MessagingException Read and parse the given RFC822 message stream till the blank line separating the header from the body. The input stream is left positioned at the start of the body. The header lines are stored internally. For efficiency, wrap a BufferedInputStream around the actual input stream and pass it as the parameter. No placeholder entries are inserted; the original order of the headers is preserved.
| |
| InternetHeaders | back to summary |
|---|---|
| public InternetHeaders(InputStream is, boolean allowutf8) throws MessagingException Read and parse the given RFC822 message stream till the blank line separating the header from the body. The input stream is left positioned at the start of the body. The header lines are stored internally. For efficiency, wrap a BufferedInputStream around the actual input stream and pass it as the parameter. No placeholder entries are inserted; the original order of the headers is preserved.
| |
| addHeader | back to summary |
|---|---|
| public void addHeader(String name, String value) Add a header with the specified name and value to the header list.
The current implementation knows about the preferred order of most
well-known headers and will insert headers in that order. In
addition, it knows that Note that RFC822 headers can only contain US-ASCII characters. | |
| addHeaderLine | back to summary |
|---|---|
| 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
| |
| getAllHeaderLines | back to summary |
|---|---|
| public Enumeration Return all the header lines as an Enumeration of Strings.
| |
| getAllHeaders | back to summary |
|---|---|
| public Enumeration Return all the headers as an Enumeration of
| |
| getHeader | back to summary |
|---|---|
| public String[] getHeader(String name) Return all the values for the specified header. The
values are String objects. Returns | |
| getHeader | back to summary |
|---|---|
| public 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. If the
delimiter is | |
| getMatchingHeaderLines | back to summary |
|---|---|
| public Enumeration Return all matching header lines as an Enumeration of Strings.
| |
| getMatchingHeaders | back to summary |
|---|---|
| public Enumeration Return all matching
| |
| getNonMatchingHeaderLines | back to summary |
|---|---|
| public Enumeration Return all non-matching header lines
| |
| getNonMatchingHeaders | back to summary |
|---|---|
| public Enumeration Return all non-matching
| |
| isEmpty | back to summary |
|---|---|
| private static final boolean isEmpty(String line) Is this line an empty (blank) line? | |
| load | back to summary |
|---|---|
| public void load(InputStream is) throws MessagingException Read and parse the given RFC822 message stream till the blank line separating the header from the body. Store the header lines inside this InternetHeaders object. The order of header lines is preserved. Note that the header lines are added into this InternetHeaders object, so any existing headers in this object will not be affected. Headers are added to the end of the existing list of headers, in order.
| |
| load | back to summary |
|---|---|
| public void load(InputStream is, boolean allowutf8) throws MessagingException Read and parse the given RFC822 message stream till the blank line separating the header from the body. Store the header lines inside this InternetHeaders object. The order of header lines is preserved. Note that the header lines are added into this InternetHeaders object, so any existing headers in this object will not be affected. Headers are added to the end of the existing list of headers, in order.
| |
| removeHeader | back to summary |
|---|---|
| public void removeHeader(String name) Remove all header entries that match the given name
| |
| setHeader | back to summary |
|---|---|
| public 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. Remove all matching headers but the first. Note that RFC822 headers can only contain US-ASCII characters | |
An InternetHeader object with a null value is used as a placeholder for headers of that name, to preserve the order of headers. A placeholder InternetHeader object with a name of ":" marks the location in the list of headers where new headers are added by default.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv String |
| Access | Constructor and Description |
|---|---|
| public | InternetHeader(String
the header line l)Constructor that takes a line and splits out the header name. |
| public | InternetHeader(String
the name of the header n, String the value of the header v)Constructor that takes a header name and value. |
| Modifier and Type | Method and Description |
|---|---|
| public String |
| line | back to summary |
|---|---|
| pack-priv String line | |
| InternetHeader | back to summary |
|---|---|
| public InternetHeader(String l) Constructor that takes a line and splits out the header name.
| |
| InternetHeader | back to summary |
|---|---|
| public InternetHeader(String n, String v) Constructor that takes a header name and value. | |
| getValue | back to summary |
|---|---|
| public String getValue() Overrides javax. Return the "value" part of the header line.
| |
| Modifier and Type | Field and Description |
|---|---|
| private Iterator | |
| private boolean | |
| private String[] | |
| private InternetHeaders. | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Object | |
| private InternetHeaders. |
| e | back to summary |
|---|---|
| private Iterator<InternetHeaders. | |
| match | back to summary |
|---|---|
| private boolean match | |
| names | back to summary |
|---|---|
| private String[] names | |
| next_header | back to summary |
|---|---|
| private InternetHeaders. | |
| want_line | back to summary |
|---|---|
| private boolean want_line | |
| MatchEnum | back to summary |
|---|---|
| pack-priv MatchEnum(List<InternetHeaders. | |
| hasMoreElements | back to summary |
|---|---|
| public boolean hasMoreElements() | |
| nextElement | back to summary |
|---|---|
| public Object nextElement() | |
| nextMatch | back to summary |
|---|---|
| private InternetHeaders. | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Header | nextElement()
Overrides javax. Implements java. |
| MatchHeaderEnum | back to summary |
|---|---|
| pack-priv MatchHeaderEnum(List<InternetHeaders. | |
| nextElement | back to summary |
|---|---|
| public Header nextElement() Overrides javax. Implements java. Doc from java. Returns the next element of this enumeration if this enumeration object has at least one more element to provide. | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public String | nextElement()
Overrides javax. Implements java. |
| MatchStringEnum | back to summary |
|---|---|
| pack-priv MatchStringEnum(List<InternetHeaders. | |
| nextElement | back to summary |
|---|---|
| public String nextElement() Overrides javax. Implements java. Doc from java. Returns the next element of this enumeration if this enumeration object has at least one more element to provide. | |