|
SunONE Application Server v8.0 PE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.mail.internet.InternetHeaders
InternetHeaders is a utility class that manages RFC822 style
headers. Given an RFC822 format message stream, it reads lines
until the blank line that indicates end of header. The input stream
is positioned at the start of the body. The lines are stored
within the object and can be extracted as either Strings or
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.
MimeUtility
Constructor Summary | |
InternetHeaders()
Create an empty InternetHeaders object. |
|
InternetHeaders(java.io.InputStream is)
Read and parse the given RFC822 message stream till the blank line separating the header from the body. |
Method Summary | |
void |
addHeader(java.lang.String name,
java.lang.String value)
Add a header with the specified name and value to the header list. |
void |
addHeaderLine(java.lang.String line)
Add an RFC822 header line to the header store. |
java.util.Enumeration |
getAllHeaderLines()
Return all the header lines as an Enumeration of Strings. |
java.util.Enumeration |
getAllHeaders()
Return all the headers as an Enumeration of Header objects. |
java.lang.String[] |
getHeader(java.lang.String name)
Return all the values for the specified header. |
java.lang.String |
getHeader(java.lang.String name,
java.lang.String delimiter)
Get all the headers for this header name, returned as a single String, with headers separated by the delimiter. |
java.util.Enumeration |
getMatchingHeaderLines(java.lang.String[] names)
Return all matching header lines as an Enumeration of Strings. |
java.util.Enumeration |
getMatchingHeaders(java.lang.String[] names)
Return all matching Header objects. |
java.util.Enumeration |
getNonMatchingHeaderLines(java.lang.String[] names)
Return all non-matching header lines |
java.util.Enumeration |
getNonMatchingHeaders(java.lang.String[] names)
Return all non-matching Header objects. |
void |
load(java.io.InputStream is)
Read and parse the given RFC822 message stream till the blank line separating the header from the body. |
void |
removeHeader(java.lang.String name)
Remove all header entries that match the given name |
void |
setHeader(java.lang.String name,
java.lang.String value)
Change the first header line that matches name to have value, adding a new header if no existing header matches. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public InternetHeaders()
public InternetHeaders(java.io.InputStream is) throws MessagingException
For efficiency, wrap a BufferedInputStream around the actual input stream and pass it as the parameter.
is
- RFC822 input streamMethod Detail |
public void load(java.io.InputStream is) throws MessagingException
Note that the header lines are added into this InternetHeaders object, so any existing headers in this object will not be affected.
is
- RFC822 input stream
MessagingException
public java.lang.String[] getHeader(java.lang.String name)
null
if no headers with the specified name exist.
name
- header name
public java.lang.String getHeader(java.lang.String name, java.lang.String delimiter)
null
, only the first header is
returned. Returns null
if no headers with the specified name exist.
name
- header namedelimiter
- delimiter
public void setHeader(java.lang.String name, java.lang.String value)
Note that RFC822 headers can only contain US-ASCII characters
name
- header namevalue
- header valuepublic void addHeader(java.lang.String name, java.lang.String value)
Note that RFC822 headers can only contain US-ASCII characters.
name
- header namevalue
- header valuepublic void removeHeader(java.lang.String name)
name
- header namepublic java.util.Enumeration getAllHeaders()
Header
objects.
public java.util.Enumeration getMatchingHeaders(java.lang.String[] names)
Header
objects.
public java.util.Enumeration getNonMatchingHeaders(java.lang.String[] names)
Header
objects.
public void addHeaderLine(java.lang.String line)
Note that RFC822 headers can only contain US-ASCII characters
line
- raw RFC822 header linepublic java.util.Enumeration getAllHeaderLines()
public java.util.Enumeration getMatchingHeaderLines(java.lang.String[] names)
public java.util.Enumeration getNonMatchingHeaderLines(java.lang.String[] names)
|
SunONE Application Server v8.0 PE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2003 Sun Microsystems, Inc. All rights reserved.