- java.lang.Object
-
- org.jvnet.mimepull.InternetHeaders
-
final class InternetHeaders extends java.lang.Object
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 orHeader
objects.This class is mostly intended for service providers. MimeMessage and MimeBody use this class for holding their headers.
A note on RFC822 and MIME headersRFC822 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.
-
-
Field Summary
Fields Modifier and Type Field Description private FinalArrayList<Hdr>
headers
-
Constructor Summary
Constructors Constructor Description InternetHeaders(MIMEParser.LineInputStream lis)
Read and parse the given RFC822 message stream till the blank line separating the header from the body.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addHeaderLine(java.lang.String line)
Add an RFC822 header line to the header store.(package private) FinalArrayList<? extends Header>
getAllHeaders()
Return all the headers as an Enumeration ofHeader
objects.(package private) java.util.List<java.lang.String>
getHeader(java.lang.String name)
Return all the values for the specified header.
-
-
-
Field Detail
-
headers
private final FinalArrayList<Hdr> headers
-
-
Constructor Detail
-
InternetHeaders
InternetHeaders(MIMEParser.LineInputStream lis)
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.Note that the header lines are added into this InternetHeaders object, so any existing headers in this object will not be affected.
- Parameters:
lis
- RFC822 input stream
-
-
Method Detail
-
getHeader
java.util.List<java.lang.String> getHeader(java.lang.String name)
Return all the values for the specified header. The values are String objects. Returnsnull
if no headers with the specified name exist.- Parameters:
name
- header name- Returns:
- array of header values, or null if none
-
getAllHeaders
FinalArrayList<? extends Header> getAllHeaders()
Return all the headers as an Enumeration ofHeader
objects.- Returns:
- Header objects
-
addHeaderLine
void addHeaderLine(java.lang.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.Note that RFC822 headers can only contain US-ASCII characters
- Parameters:
line
- raw RFC822 header line
-
-