< prev index next >
jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/packaging/mime/internet/InternetHeaders.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 46,73 ****
* 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
! * {@link Header} objects. <p>
! * <p/>
* This class is mostly intended for service providers. MimeMessage
! * and MimeBody use this class for holding their headers. <p>
! * <p/>
! * <hr> <strong>A note on RFC822 and MIME headers</strong><p>
! * <p/>
* RFC822 and MIME header fields <strong>must</strong> 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 <code>setHeader</code>, <code>addHeader</code>, and
* <code>addHeaderLine</code> 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. <p>
*
* @author John Mani
* @author Bill Shannon
* @see MimeUtility
*/
--- 46,72 ----
* 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
! * {@link Header} objects.
! * <p>
* This class is mostly intended for service providers. MimeMessage
! * and MimeBody use this class for holding their headers.
! * <hr> <strong>A note on RFC822 and MIME headers</strong>
! * <p>
* RFC822 and MIME header fields <strong>must</strong> 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 <code>setHeader</code>, <code>addHeader</code>, and
* <code>addHeaderLine</code> 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.
*
* @author John Mani
* @author Bill Shannon
* @see MimeUtility
*/
*** 88,118 ****
/**
* 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. <p>
! * <p/>
* For efficiency, wrap a BufferedInputStream around the actual
* input stream and pass it as the parameter.
*
* @param is RFC822 input stream
*/
public InternetHeaders(InputStream is) throws MessagingException {
load(is);
}
/**
* 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. <p>
! * <p/>
* Note that the header lines are added into this InternetHeaders
* object, so any existing headers in this object will not be
* affected.
*
* @param is RFC822 input stream
*/
public void load(InputStream is) throws MessagingException {
// Read header lines until a blank line. It is valid
// to have BodyParts with no header lines.
String line;
--- 87,119 ----
/**
* 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.
! * <p>
* For efficiency, wrap a BufferedInputStream around the actual
* input stream and pass it as the parameter.
*
* @param is RFC822 input stream
+ * @exception MessagingException in case of error
*/
public InternetHeaders(InputStream is) throws MessagingException {
load(is);
}
/**
* 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.
! * <p>
* Note that the header lines are added into this InternetHeaders
* object, so any existing headers in this object will not be
* affected.
*
* @param is RFC822 input stream
+ * @exception MessagingException in case of error
*/
public void load(InputStream is) throws MessagingException {
// Read header lines until a blank line. It is valid
// to have BodyParts with no header lines.
String line;
*** 206,218 ****
}
/**
* 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. <p>
! * <p/>
! * Note that RFC822 headers can only contain US-ASCII characters
*
* @param name header name
* @param value header value
*/
public void setHeader(String name, String value) {
--- 207,219 ----
}
/**
* 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.
! * <p>
! * Note that RFC822 headers can only contain US-ASCII characters.
*
* @param name header name
* @param value header value
*/
public void setHeader(String name, String value) {
*** 240,251 ****
addHeader(name, value);
}
}
/**
! * Add a header with the specified name and value to the header list. <p>
! * <p/>
* Note that RFC822 headers can only contain US-ASCII characters.
*
* @param name header name
* @param value header value
*/
--- 241,251 ----
addHeader(name, value);
}
}
/**
! * Add a header with the specified name and value to the header list.
* Note that RFC822 headers can only contain US-ASCII characters.
*
* @param name header name
* @param value header value
*/
*** 283,301 ****
* Return all the headers as an Enumeration of
* {@link Header} objects.
*
* @return Header objects
*/
! public List<? extends Header> getAllHeaders() {
return headers; // conceptually it should be read-only, but for performance reason I'm not wrapping it here
}
/**
* 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. <p>
! * <p/>
* Note that RFC822 headers can only contain US-ASCII characters
*
* @param line raw RFC822 header line
*/
public void addHeaderLine(String line) {
--- 283,301 ----
* Return all the headers as an Enumeration of
* {@link Header} objects.
*
* @return Header objects
*/
! public FinalArrayList<hdr> getAllHeaders() {
return headers; // conceptually it should be read-only, but for performance reason I'm not wrapping it here
}
/**
* 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.
! * <p>
* Note that RFC822 headers can only contain US-ASCII characters
*
* @param line raw RFC822 header line
*/
public void addHeaderLine(String line) {
*** 314,331 ****
--- 314,335 ----
}
}
/**
* Return all the header lines as a collection
+ *
+ * @return list of header lines.
*/
public List<String> getAllHeaderLines() {
if(headerValueView==null)
headerValueView = new AbstractList<String>() {
+ @Override
public String get(int index) {
return headers.get(index).line;
}
+ @Override
public int size() {
return headers.size();
}
};
return headerValueView;
*** 366,382 ****
--- 370,388 ----
}
/*
* Return the "name" part of the header line.
*/
+ @Override
public String getName() {
return name;
}
/*
* Return the "value" part of the header line.
*/
+ @Override
public String getValue() {
int i = line.indexOf(':');
if (i < 0)
return line;
< prev index next >