javax.mail.internet
public class InternetHeaders extends Object
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.
Modifier and Type | Class and Description |
---|---|
protected static class |
InternetHeaders.InternetHeader |
Modifier and Type | Field and Description |
---|---|
protected List |
headers
The list of headers.
|
Constructor and Description |
---|
InternetHeaders()
Constructor for an empty InternetHeaders.
|
InternetHeaders(InputStream is)
Constructor with an RFC 822 message stream.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected List headers
public InternetHeaders()
public InternetHeaders(InputStream is) throws MessagingException
is
- an RFC 822 input streamMessagingException
public void load(InputStream is) throws MessagingException
is
- an RFC 822 input streamMessagingException
public String[] getHeader(String name)
name
- the header namepublic String getHeader(String name, String delimiter)
null
, only the first header is returned.name
- the header namedelimiter
- the delimiterpublic void setHeader(String name, String value)
name
- the header namevalue
- the header valuepublic void addHeader(String name, String value)
name
- the header namevalue
- the header valuepublic void removeHeader(String name)
name
- the header namepublic Enumeration getAllHeaders()
public Enumeration getMatchingHeaders(String[] names)
names
- the names to matchpublic Enumeration getNonMatchingHeaders(String[] names)
names
- the names not to matchpublic void addHeaderLine(String line)
line
- the raw RFC 822 header-linepublic Enumeration getAllHeaderLines()
public Enumeration getMatchingHeaderLines(String[] names)
public Enumeration getNonMatchingHeaderLines(String[] names)
© Copyright 2003, 2004 The Free Software Foundation, All rights reserved