public class MimeHeaders {
// Public Constructors
public MimeHeaders( );
// Public Instance Methods
public void addHeader( String name, String value);
public Iterator getAllHeaders( );
// default:Itr
public String[ ] getHeader( String name);
public Iterator getMatchingHeaders(String[ ] names);
public Iterator getNonMatchingHeaders(String[ ] names);
public void removeAllHeaders( );
public void removeHeader( String name);
public void setHeader( String name, String value);
}
MimeHeaders is a container class that represents a
group of MIME headers associated with a SOAP message. A message that
has no attachments has a single set of MIME headers that can be
obtained by calling the getMimeHeaders( ) method
of its SOAPMessage object. A message with
attachments has additional sets of independent MIME headers
associated with the SOAP envelope (available from the
SOAPPart object) and with each attachment.
MimeHeaders manages a set of
MimeHeader objects, each of which represents a
single header name/value combination. It is possible for a header to
have multiple values, in which case each value has its own
MimeHeader object. The addHeader(
) method creates a new entry with a given name and value,
leaving all existing entries with the same name intact. The
setHeader( ) method adds a new entry if a header
with the given name does not already exist; otherwise, it replaces
the value of the first header in the collection with the given name,
as illustrated by the following code snippet, in which
headers is a reference to a
MimeHeaders object:
headers.setHeader("Content-Length", "1024");
headers.setHeader("Content-Type", "text/plain");
headers.setHeader("Content-Length", "2048");
// Replaces the value added earlier
This code creates a Content-Type header with the
value text/plain and a
Content-Length header with the value
2048.
The removeHeader( ) method removes all MIME
headers whose name matches the supplied value. Note that the name
comparison performed by this method (and all
MimeHeaders methods) is case-insensitive. The
removeAllHeaders( ) method removes all headers,
leaving an empty container.
There are four methods that let you obtain some or all of the headers
in a MimeHeaders object. The getHeader(
) method accepts a header name and returns an array
containing all of the values associated with that header, or
null if there are none. The other three methods
all return an Iterator containing objects of type
MimeHeader. The getAllHeaders(
) method returns all headers and their values.
getMatchingHeaders( ) accepts a list of header
names and returns the MimeHeader objects for all
headers whose names appear in the given list.
getNonMatchingHeaders( ) returns the
MimeHeader objects for all headers whose names do
not appear in the list; if an empty list of names is supplied, then
all headers and their associated values are returned.