jaxws/src/share/classes/javax/xml/soap/AttachmentPart.java
author asaha
Fri, 07 Aug 2009 11:27:00 -0700
changeset 3530 18fb7507984b
parent 2678 57cf2a1c1a05
permissions -rw-r--r--
6813167: 6u14 JAX-WS audit mutable static bugs 6803688: Integrate latest JAX-WS (2.1.6) in to JDK 6u14 Reviewed-by: darcy, ramap
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
474761f14bca Initial load
duke
parents:
diff changeset
     1
/*
474761f14bca Initial load
duke
parents:
diff changeset
     2
 * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
474761f14bca Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
474761f14bca Initial load
duke
parents:
diff changeset
     4
 *
474761f14bca Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
474761f14bca Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
474761f14bca Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
474761f14bca Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
474761f14bca Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
474761f14bca Initial load
duke
parents:
diff changeset
    10
 *
474761f14bca Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
474761f14bca Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
474761f14bca Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
474761f14bca Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
474761f14bca Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
474761f14bca Initial load
duke
parents:
diff changeset
    16
 *
474761f14bca Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
474761f14bca Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
474761f14bca Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
474761f14bca Initial load
duke
parents:
diff changeset
    20
 *
474761f14bca Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
474761f14bca Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
474761f14bca Initial load
duke
parents:
diff changeset
    23
 * have any questions.
474761f14bca Initial load
duke
parents:
diff changeset
    24
 */
2678
57cf2a1c1a05 6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents: 8
diff changeset
    25
/*
3530
18fb7507984b 6813167: 6u14 JAX-WS audit mutable static bugs
asaha
parents: 2678
diff changeset
    26
 * $Id: AttachmentPart.java,v 1.13 2006/03/30 00:59:38 ofung Exp $
18fb7507984b 6813167: 6u14 JAX-WS audit mutable static bugs
asaha
parents: 2678
diff changeset
    27
 * $Revision: 1.13 $
18fb7507984b 6813167: 6u14 JAX-WS audit mutable static bugs
asaha
parents: 2678
diff changeset
    28
 * $Date: 2006/03/30 00:59:38 $
2678
57cf2a1c1a05 6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents: 8
diff changeset
    29
 */
57cf2a1c1a05 6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents: 8
diff changeset
    30
57cf2a1c1a05 6831313: update jaxws in OpenJDK7 to 2.1 plus bug fixes from OpenJDK 6
tbell
parents: 8
diff changeset
    31
8
474761f14bca Initial load
duke
parents:
diff changeset
    32
package javax.xml.soap;
474761f14bca Initial load
duke
parents:
diff changeset
    33
474761f14bca Initial load
duke
parents:
diff changeset
    34
import java.io.InputStream;
474761f14bca Initial load
duke
parents:
diff changeset
    35
import java.io.Reader;
474761f14bca Initial load
duke
parents:
diff changeset
    36
import java.util.Iterator;
474761f14bca Initial load
duke
parents:
diff changeset
    37
474761f14bca Initial load
duke
parents:
diff changeset
    38
import javax.activation.DataHandler;
474761f14bca Initial load
duke
parents:
diff changeset
    39
474761f14bca Initial load
duke
parents:
diff changeset
    40
/**
474761f14bca Initial load
duke
parents:
diff changeset
    41
 * A single attachment to a <code>SOAPMessage</code> object. A <code>SOAPMessage</code>
474761f14bca Initial load
duke
parents:
diff changeset
    42
 * object may contain zero, one, or many <code>AttachmentPart</code> objects.
474761f14bca Initial load
duke
parents:
diff changeset
    43
 * Each <code>AttachmentPart</code> object consists of two parts,
474761f14bca Initial load
duke
parents:
diff changeset
    44
 * application-specific content and associated MIME headers. The
474761f14bca Initial load
duke
parents:
diff changeset
    45
 * MIME headers consists of name/value pairs that can be used to
474761f14bca Initial load
duke
parents:
diff changeset
    46
 * identify and describe the content.
474761f14bca Initial load
duke
parents:
diff changeset
    47
 * <p>
474761f14bca Initial load
duke
parents:
diff changeset
    48
 * An <code>AttachmentPart</code> object must conform to certain standards.
474761f14bca Initial load
duke
parents:
diff changeset
    49
 * <OL>
474761f14bca Initial load
duke
parents:
diff changeset
    50
 * <LI>It must conform to <a href="http://www.ietf.org/rfc/rfc2045.txt">
474761f14bca Initial load
duke
parents:
diff changeset
    51
 *     MIME [RFC2045] standards</a>
474761f14bca Initial load
duke
parents:
diff changeset
    52
 * <LI>It MUST contain content
474761f14bca Initial load
duke
parents:
diff changeset
    53
 * <LI>The header portion MUST include the following header:
474761f14bca Initial load
duke
parents:
diff changeset
    54
 *  <UL>
474761f14bca Initial load
duke
parents:
diff changeset
    55
 *   <LI><code>Content-Type</code><br>
474761f14bca Initial load
duke
parents:
diff changeset
    56
 *       This header identifies the type of data in the content of an
474761f14bca Initial load
duke
parents:
diff changeset
    57
 *       <code>AttachmentPart</code> object and MUST conform to [RFC2045].
474761f14bca Initial load
duke
parents:
diff changeset
    58
 *       The following is an example of a Content-Type header:
474761f14bca Initial load
duke
parents:
diff changeset
    59
 *       <PRE>
474761f14bca Initial load
duke
parents:
diff changeset
    60
 *       Content-Type:  application/xml
474761f14bca Initial load
duke
parents:
diff changeset
    61
 *       </PRE>
474761f14bca Initial load
duke
parents:
diff changeset
    62
 *       The following line of code, in which <code>ap</code> is an
474761f14bca Initial load
duke
parents:
diff changeset
    63
 *       <code>AttachmentPart</code> object, sets the header shown in
474761f14bca Initial load
duke
parents:
diff changeset
    64
 *       the previous example.
474761f14bca Initial load
duke
parents:
diff changeset
    65
 *       <PRE>
474761f14bca Initial load
duke
parents:
diff changeset
    66
 *       ap.setMimeHeader("Content-Type", "application/xml");
474761f14bca Initial load
duke
parents:
diff changeset
    67
 *       </PRE>
474761f14bca Initial load
duke
parents:
diff changeset
    68
 * <p>
474761f14bca Initial load
duke
parents:
diff changeset
    69
 *  </UL>
474761f14bca Initial load
duke
parents:
diff changeset
    70
 * </OL>
474761f14bca Initial load
duke
parents:
diff changeset
    71
 * <p>
474761f14bca Initial load
duke
parents:
diff changeset
    72
 * There are no restrictions on the content portion of an <code>
474761f14bca Initial load
duke
parents:
diff changeset
    73
 * AttachmentPart</code> object. The content may be anything from a
474761f14bca Initial load
duke
parents:
diff changeset
    74
 * simple plain text object to a complex XML document or image file.
474761f14bca Initial load
duke
parents:
diff changeset
    75
 *
474761f14bca Initial load
duke
parents:
diff changeset
    76
 * <p>
474761f14bca Initial load
duke
parents:
diff changeset
    77
 * An <code>AttachmentPart</code> object is created with the method
474761f14bca Initial load
duke
parents:
diff changeset
    78
 * <code>SOAPMessage.createAttachmentPart</code>. After setting its MIME headers,
474761f14bca Initial load
duke
parents:
diff changeset
    79
 *  the <code>AttachmentPart</code> object is added to the message
474761f14bca Initial load
duke
parents:
diff changeset
    80
 * that created it with the method <code>SOAPMessage.addAttachmentPart</code>.
474761f14bca Initial load
duke
parents:
diff changeset
    81
 *
474761f14bca Initial load
duke
parents:
diff changeset
    82
 * <p>
474761f14bca Initial load
duke
parents:
diff changeset
    83
 * The following code fragment, in which <code>m</code> is a
474761f14bca Initial load
duke
parents:
diff changeset
    84
 * <code>SOAPMessage</code> object and <code>contentStringl</code> is a
474761f14bca Initial load
duke
parents:
diff changeset
    85
 * <code>String</code>, creates an instance of <code>AttachmentPart</code>,
474761f14bca Initial load
duke
parents:
diff changeset
    86
 * sets the <code>AttachmentPart</code> object with some content and
474761f14bca Initial load
duke
parents:
diff changeset
    87
 * header information, and adds the <code>AttachmentPart</code> object to
474761f14bca Initial load
duke
parents:
diff changeset
    88
 * the <code>SOAPMessage</code> object.
474761f14bca Initial load
duke
parents:
diff changeset
    89
 * <PRE>
474761f14bca Initial load
duke
parents:
diff changeset
    90
 *     AttachmentPart ap1 = m.createAttachmentPart();
474761f14bca Initial load
duke
parents:
diff changeset
    91
 *     ap1.setContent(contentString1, "text/plain");
474761f14bca Initial load
duke
parents:
diff changeset
    92
 *     m.addAttachmentPart(ap1);
474761f14bca Initial load
duke
parents:
diff changeset
    93
 * </PRE>
474761f14bca Initial load
duke
parents:
diff changeset
    94
 *
474761f14bca Initial load
duke
parents:
diff changeset
    95
 *
474761f14bca Initial load
duke
parents:
diff changeset
    96
 * <p>
474761f14bca Initial load
duke
parents:
diff changeset
    97
 * The following code fragment creates and adds a second
474761f14bca Initial load
duke
parents:
diff changeset
    98
 * <code>AttachmentPart</code> instance to the same message. <code>jpegData</code>
474761f14bca Initial load
duke
parents:
diff changeset
    99
 * is a binary byte buffer representing the jpeg file.
474761f14bca Initial load
duke
parents:
diff changeset
   100
 * <PRE>
474761f14bca Initial load
duke
parents:
diff changeset
   101
 *     AttachmentPart ap2 = m.createAttachmentPart();
474761f14bca Initial load
duke
parents:
diff changeset
   102
 *     byte[] jpegData =  ...;
474761f14bca Initial load
duke
parents:
diff changeset
   103
 *     ap2.setContent(new ByteArrayInputStream(jpegData), "image/jpeg");
474761f14bca Initial load
duke
parents:
diff changeset
   104
 *     m.addAttachmentPart(ap2);
474761f14bca Initial load
duke
parents:
diff changeset
   105
 * </PRE>
474761f14bca Initial load
duke
parents:
diff changeset
   106
 * <p>
474761f14bca Initial load
duke
parents:
diff changeset
   107
 * The <code>getContent</code> method retrieves the contents and header from
474761f14bca Initial load
duke
parents:
diff changeset
   108
 * an <code>AttachmentPart</code> object. Depending on the
474761f14bca Initial load
duke
parents:
diff changeset
   109
 * <code>DataContentHandler</code> objects present, the returned
474761f14bca Initial load
duke
parents:
diff changeset
   110
 * <code>Object</code> can either be a typed Java object corresponding
474761f14bca Initial load
duke
parents:
diff changeset
   111
 * to the MIME type or an <code>InputStream</code> object that contains the
474761f14bca Initial load
duke
parents:
diff changeset
   112
 * content as bytes.
474761f14bca Initial load
duke
parents:
diff changeset
   113
 * <PRE>
474761f14bca Initial load
duke
parents:
diff changeset
   114
 *     String content1 = ap1.getContent();
474761f14bca Initial load
duke
parents:
diff changeset
   115
 *     java.io.InputStream content2 = ap2.getContent();
474761f14bca Initial load
duke
parents:
diff changeset
   116
 * </PRE>
474761f14bca Initial load
duke
parents:
diff changeset
   117
 *
474761f14bca Initial load
duke
parents:
diff changeset
   118
 * The method <code>clearContent</code> removes all the content from an
474761f14bca Initial load
duke
parents:
diff changeset
   119
 * <code>AttachmentPart</code> object but does not affect its header information.
474761f14bca Initial load
duke
parents:
diff changeset
   120
 * <PRE>
474761f14bca Initial load
duke
parents:
diff changeset
   121
 *     ap1.clearContent();
474761f14bca Initial load
duke
parents:
diff changeset
   122
 * </PRE>
474761f14bca Initial load
duke
parents:
diff changeset
   123
 */
474761f14bca Initial load
duke
parents:
diff changeset
   124
474761f14bca Initial load
duke
parents:
diff changeset
   125
public abstract class AttachmentPart {
474761f14bca Initial load
duke
parents:
diff changeset
   126
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   127
     * Returns the number of bytes in this <code>AttachmentPart</code>
474761f14bca Initial load
duke
parents:
diff changeset
   128
     * object.
474761f14bca Initial load
duke
parents:
diff changeset
   129
     *
474761f14bca Initial load
duke
parents:
diff changeset
   130
     * @return the size of this <code>AttachmentPart</code> object in bytes
474761f14bca Initial load
duke
parents:
diff changeset
   131
     *         or -1 if the size cannot be determined
474761f14bca Initial load
duke
parents:
diff changeset
   132
     * @exception SOAPException if the content of this attachment is
474761f14bca Initial load
duke
parents:
diff changeset
   133
     *            corrupted of if there was an exception while trying
474761f14bca Initial load
duke
parents:
diff changeset
   134
     *            to determine the size.
474761f14bca Initial load
duke
parents:
diff changeset
   135
     */
474761f14bca Initial load
duke
parents:
diff changeset
   136
    public abstract int getSize() throws SOAPException;
474761f14bca Initial load
duke
parents:
diff changeset
   137
474761f14bca Initial load
duke
parents:
diff changeset
   138
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   139
     * Clears out the content of this <code>AttachmentPart</code> object.
474761f14bca Initial load
duke
parents:
diff changeset
   140
     * The MIME header portion is left untouched.
474761f14bca Initial load
duke
parents:
diff changeset
   141
     */
474761f14bca Initial load
duke
parents:
diff changeset
   142
    public abstract void clearContent();
474761f14bca Initial load
duke
parents:
diff changeset
   143
474761f14bca Initial load
duke
parents:
diff changeset
   144
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   145
     * Gets the content of this <code>AttachmentPart</code> object as a Java
474761f14bca Initial load
duke
parents:
diff changeset
   146
     * object. The type of the returned Java object depends on (1) the
474761f14bca Initial load
duke
parents:
diff changeset
   147
     * <code>DataContentHandler</code> object that is used to interpret the bytes
474761f14bca Initial load
duke
parents:
diff changeset
   148
     * and (2) the <code>Content-Type</code> given in the header.
474761f14bca Initial load
duke
parents:
diff changeset
   149
     * <p>
474761f14bca Initial load
duke
parents:
diff changeset
   150
     * For the MIME content types "text/plain", "text/html" and "text/xml", the
474761f14bca Initial load
duke
parents:
diff changeset
   151
     * <code>DataContentHandler</code> object does the conversions to and
474761f14bca Initial load
duke
parents:
diff changeset
   152
     * from the Java types corresponding to the MIME types.
474761f14bca Initial load
duke
parents:
diff changeset
   153
     * For other MIME types,the <code>DataContentHandler</code> object
474761f14bca Initial load
duke
parents:
diff changeset
   154
     * can return an <code>InputStream</code> object that contains the content data
474761f14bca Initial load
duke
parents:
diff changeset
   155
     * as raw bytes.
474761f14bca Initial load
duke
parents:
diff changeset
   156
     * <p>
474761f14bca Initial load
duke
parents:
diff changeset
   157
     * A SAAJ-compliant implementation must, as a minimum, return a
474761f14bca Initial load
duke
parents:
diff changeset
   158
     * <code>java.lang.String</code> object corresponding to any content
474761f14bca Initial load
duke
parents:
diff changeset
   159
     * stream with a <code>Content-Type</code> value of
474761f14bca Initial load
duke
parents:
diff changeset
   160
     * <code>text/plain</code>, a
474761f14bca Initial load
duke
parents:
diff changeset
   161
     * <code>javax.xml.transform.stream.StreamSource</code> object corresponding to a
474761f14bca Initial load
duke
parents:
diff changeset
   162
     * content stream with a <code>Content-Type</code> value of
474761f14bca Initial load
duke
parents:
diff changeset
   163
     * <code>text/xml</code>, a <code>java.awt.Image</code> object
474761f14bca Initial load
duke
parents:
diff changeset
   164
     * corresponding to a content stream with a
474761f14bca Initial load
duke
parents:
diff changeset
   165
     * <code>Content-Type</code> value of <code>image/gif</code> or
474761f14bca Initial load
duke
parents:
diff changeset
   166
     * <code>image/jpeg</code>.  For those content types that an
474761f14bca Initial load
duke
parents:
diff changeset
   167
     * installed <code>DataContentHandler</code> object does not understand, the
474761f14bca Initial load
duke
parents:
diff changeset
   168
     * <code>DataContentHandler</code> object is required to return a
474761f14bca Initial load
duke
parents:
diff changeset
   169
     * <code>java.io.InputStream</code> object with the raw bytes.
474761f14bca Initial load
duke
parents:
diff changeset
   170
     *
474761f14bca Initial load
duke
parents:
diff changeset
   171
     * @return a Java object with the content of this <code>AttachmentPart</code>
474761f14bca Initial load
duke
parents:
diff changeset
   172
     *         object
474761f14bca Initial load
duke
parents:
diff changeset
   173
     *
474761f14bca Initial load
duke
parents:
diff changeset
   174
     * @exception SOAPException if there is no content set into this
474761f14bca Initial load
duke
parents:
diff changeset
   175
     *            <code>AttachmentPart</code> object or if there was a data
474761f14bca Initial load
duke
parents:
diff changeset
   176
     *            transformation error
474761f14bca Initial load
duke
parents:
diff changeset
   177
     */
474761f14bca Initial load
duke
parents:
diff changeset
   178
    public abstract Object getContent() throws SOAPException;
474761f14bca Initial load
duke
parents:
diff changeset
   179
474761f14bca Initial load
duke
parents:
diff changeset
   180
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   181
     * Gets the content of this <code>AttachmentPart</code> object as an
474761f14bca Initial load
duke
parents:
diff changeset
   182
     * InputStream as if a call had been made to <code>getContent</code> and no
474761f14bca Initial load
duke
parents:
diff changeset
   183
     * <code>DataContentHandler</code> had been registered for the
474761f14bca Initial load
duke
parents:
diff changeset
   184
     * <code>content-type</code> of this <code>AttachmentPart</code>.
474761f14bca Initial load
duke
parents:
diff changeset
   185
     *<p>
474761f14bca Initial load
duke
parents:
diff changeset
   186
     * Note that reading from the returned InputStream would result in consuming
474761f14bca Initial load
duke
parents:
diff changeset
   187
     * the data in the stream. It is the responsibility of the caller to reset
474761f14bca Initial load
duke
parents:
diff changeset
   188
     * the InputStream appropriately before calling a Subsequent API. If a copy
474761f14bca Initial load
duke
parents:
diff changeset
   189
     * of the raw attachment content is required then the {@link #getRawContentBytes} API
474761f14bca Initial load
duke
parents:
diff changeset
   190
     * should be used instead.
474761f14bca Initial load
duke
parents:
diff changeset
   191
     *
474761f14bca Initial load
duke
parents:
diff changeset
   192
     * @return an <code>InputStream</code> from which the raw data contained by
474761f14bca Initial load
duke
parents:
diff changeset
   193
     *      the <code>AttachmentPart</code> can be accessed.
474761f14bca Initial load
duke
parents:
diff changeset
   194
     *
474761f14bca Initial load
duke
parents:
diff changeset
   195
     * @throws SOAPException if there is no content set into this
474761f14bca Initial load
duke
parents:
diff changeset
   196
     *      <code>AttachmentPart</code> object or if there was a data
474761f14bca Initial load
duke
parents:
diff changeset
   197
     *      transformation error.
474761f14bca Initial load
duke
parents:
diff changeset
   198
     *
474761f14bca Initial load
duke
parents:
diff changeset
   199
     * @since SAAJ 1.3
474761f14bca Initial load
duke
parents:
diff changeset
   200
     * @see #getRawContentBytes
474761f14bca Initial load
duke
parents:
diff changeset
   201
     */
474761f14bca Initial load
duke
parents:
diff changeset
   202
    public abstract InputStream getRawContent() throws SOAPException;
474761f14bca Initial load
duke
parents:
diff changeset
   203
474761f14bca Initial load
duke
parents:
diff changeset
   204
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   205
     * Gets the content of this <code>AttachmentPart</code> object as a
474761f14bca Initial load
duke
parents:
diff changeset
   206
     * byte[] array as if a call had been made to <code>getContent</code> and no
474761f14bca Initial load
duke
parents:
diff changeset
   207
     * <code>DataContentHandler</code> had been registered for the
474761f14bca Initial load
duke
parents:
diff changeset
   208
     * <code>content-type</code> of this <code>AttachmentPart</code>.
474761f14bca Initial load
duke
parents:
diff changeset
   209
     *
474761f14bca Initial load
duke
parents:
diff changeset
   210
     * @return a <code>byte[]</code> array containing the raw data of the
474761f14bca Initial load
duke
parents:
diff changeset
   211
     *      <code>AttachmentPart</code>.
474761f14bca Initial load
duke
parents:
diff changeset
   212
     *
474761f14bca Initial load
duke
parents:
diff changeset
   213
     * @throws SOAPException if there is no content set into this
474761f14bca Initial load
duke
parents:
diff changeset
   214
     *      <code>AttachmentPart</code> object or if there was a data
474761f14bca Initial load
duke
parents:
diff changeset
   215
     *      transformation error.
474761f14bca Initial load
duke
parents:
diff changeset
   216
     *
474761f14bca Initial load
duke
parents:
diff changeset
   217
     * @since SAAJ 1.3
474761f14bca Initial load
duke
parents:
diff changeset
   218
     */
474761f14bca Initial load
duke
parents:
diff changeset
   219
    public abstract byte[] getRawContentBytes() throws SOAPException;
474761f14bca Initial load
duke
parents:
diff changeset
   220
474761f14bca Initial load
duke
parents:
diff changeset
   221
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   222
     * Returns an <code>InputStream</code> which can be used to obtain the
474761f14bca Initial load
duke
parents:
diff changeset
   223
     * content of <code>AttachmentPart</code>  as Base64 encoded
474761f14bca Initial load
duke
parents:
diff changeset
   224
     * character data, this method would base64 encode the raw bytes
474761f14bca Initial load
duke
parents:
diff changeset
   225
     * of the attachment and return.
474761f14bca Initial load
duke
parents:
diff changeset
   226
     *
474761f14bca Initial load
duke
parents:
diff changeset
   227
     * @return an <code>InputStream</code> from which the Base64 encoded
474761f14bca Initial load
duke
parents:
diff changeset
   228
     *       <code>AttachmentPart</code> can be read.
474761f14bca Initial load
duke
parents:
diff changeset
   229
     *
474761f14bca Initial load
duke
parents:
diff changeset
   230
     * @throws SOAPException if there is no content set into this
474761f14bca Initial load
duke
parents:
diff changeset
   231
     *      <code>AttachmentPart</code> object or if there was a data
474761f14bca Initial load
duke
parents:
diff changeset
   232
     *      transformation error.
474761f14bca Initial load
duke
parents:
diff changeset
   233
     *
474761f14bca Initial load
duke
parents:
diff changeset
   234
     * @since SAAJ 1.3
474761f14bca Initial load
duke
parents:
diff changeset
   235
     */
474761f14bca Initial load
duke
parents:
diff changeset
   236
    public abstract InputStream getBase64Content() throws SOAPException;
474761f14bca Initial load
duke
parents:
diff changeset
   237
474761f14bca Initial load
duke
parents:
diff changeset
   238
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   239
     * Sets the content of this attachment part to that of the given
474761f14bca Initial load
duke
parents:
diff changeset
   240
     * <code>Object</code> and sets the value of the <code>Content-Type</code>
474761f14bca Initial load
duke
parents:
diff changeset
   241
     * header to the given type. The type of the
474761f14bca Initial load
duke
parents:
diff changeset
   242
     * <code>Object</code> should correspond to the value given for the
474761f14bca Initial load
duke
parents:
diff changeset
   243
     * <code>Content-Type</code>. This depends on the particular
474761f14bca Initial load
duke
parents:
diff changeset
   244
     * set of <code>DataContentHandler</code> objects in use.
474761f14bca Initial load
duke
parents:
diff changeset
   245
     *
474761f14bca Initial load
duke
parents:
diff changeset
   246
     *
474761f14bca Initial load
duke
parents:
diff changeset
   247
     * @param object the Java object that makes up the content for
474761f14bca Initial load
duke
parents:
diff changeset
   248
     *               this attachment part
474761f14bca Initial load
duke
parents:
diff changeset
   249
     * @param contentType the MIME string that specifies the type of
474761f14bca Initial load
duke
parents:
diff changeset
   250
     *                  the content
474761f14bca Initial load
duke
parents:
diff changeset
   251
     *
474761f14bca Initial load
duke
parents:
diff changeset
   252
     * @exception IllegalArgumentException may be thrown if the contentType
474761f14bca Initial load
duke
parents:
diff changeset
   253
     *            does not match the type of the content object, or if there
474761f14bca Initial load
duke
parents:
diff changeset
   254
     *            was no <code>DataContentHandler</code> object for this
474761f14bca Initial load
duke
parents:
diff changeset
   255
     *            content object
474761f14bca Initial load
duke
parents:
diff changeset
   256
     *
474761f14bca Initial load
duke
parents:
diff changeset
   257
     * @see #getContent
474761f14bca Initial load
duke
parents:
diff changeset
   258
     */
474761f14bca Initial load
duke
parents:
diff changeset
   259
    public abstract void setContent(Object object, String contentType);
474761f14bca Initial load
duke
parents:
diff changeset
   260
474761f14bca Initial load
duke
parents:
diff changeset
   261
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   262
     * Sets the content of this attachment part to that contained by the
474761f14bca Initial load
duke
parents:
diff changeset
   263
     * <code>InputStream</code> <code>content</code> and sets the value of the
474761f14bca Initial load
duke
parents:
diff changeset
   264
     * <code>Content-Type</code> header to the value contained in
474761f14bca Initial load
duke
parents:
diff changeset
   265
     * <code>contentType</code>.
474761f14bca Initial load
duke
parents:
diff changeset
   266
     * <P>
474761f14bca Initial load
duke
parents:
diff changeset
   267
     *  A subsequent call to getSize() may not be an exact measure
474761f14bca Initial load
duke
parents:
diff changeset
   268
     *  of the content size.
474761f14bca Initial load
duke
parents:
diff changeset
   269
     *
474761f14bca Initial load
duke
parents:
diff changeset
   270
     * @param content the raw data to add to the attachment part
474761f14bca Initial load
duke
parents:
diff changeset
   271
     * @param contentType the value to set into the <code>Content-Type</code>
474761f14bca Initial load
duke
parents:
diff changeset
   272
     * header
474761f14bca Initial load
duke
parents:
diff changeset
   273
     *
474761f14bca Initial load
duke
parents:
diff changeset
   274
     * @exception SOAPException if an there is an error in setting the content
474761f14bca Initial load
duke
parents:
diff changeset
   275
     * @exception NullPointerException if <code>content</code> is null
474761f14bca Initial load
duke
parents:
diff changeset
   276
     * @since SAAJ 1.3
474761f14bca Initial load
duke
parents:
diff changeset
   277
     */
474761f14bca Initial load
duke
parents:
diff changeset
   278
    public abstract void setRawContent(InputStream content, String contentType) throws SOAPException;
474761f14bca Initial load
duke
parents:
diff changeset
   279
474761f14bca Initial load
duke
parents:
diff changeset
   280
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   281
     * Sets the content of this attachment part to that contained by the
474761f14bca Initial load
duke
parents:
diff changeset
   282
     * <code>byte[]</code> array <code>content</code> and sets the value of the
474761f14bca Initial load
duke
parents:
diff changeset
   283
     * <code>Content-Type</code> header to the value contained in
474761f14bca Initial load
duke
parents:
diff changeset
   284
     * <code>contentType</code>.
474761f14bca Initial load
duke
parents:
diff changeset
   285
     *
474761f14bca Initial load
duke
parents:
diff changeset
   286
     * @param content the raw data to add to the attachment part
474761f14bca Initial load
duke
parents:
diff changeset
   287
     * @param contentType the value to set into the <code>Content-Type</code>
474761f14bca Initial load
duke
parents:
diff changeset
   288
     * header
474761f14bca Initial load
duke
parents:
diff changeset
   289
     * @param offset the offset in the byte array of the content
474761f14bca Initial load
duke
parents:
diff changeset
   290
     * @param len the number of bytes that form the content
474761f14bca Initial load
duke
parents:
diff changeset
   291
     *
474761f14bca Initial load
duke
parents:
diff changeset
   292
     * @exception SOAPException if an there is an error in setting the content
474761f14bca Initial load
duke
parents:
diff changeset
   293
     * or content is null
474761f14bca Initial load
duke
parents:
diff changeset
   294
     * @since SAAJ 1.3
474761f14bca Initial load
duke
parents:
diff changeset
   295
     */
474761f14bca Initial load
duke
parents:
diff changeset
   296
    public abstract void setRawContentBytes(
474761f14bca Initial load
duke
parents:
diff changeset
   297
        byte[] content, int offset, int len,  String contentType)
474761f14bca Initial load
duke
parents:
diff changeset
   298
        throws SOAPException;
474761f14bca Initial load
duke
parents:
diff changeset
   299
474761f14bca Initial load
duke
parents:
diff changeset
   300
474761f14bca Initial load
duke
parents:
diff changeset
   301
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   302
     * Sets the content of this attachment part from the Base64 source
474761f14bca Initial load
duke
parents:
diff changeset
   303
     * <code>InputStream</code>  and sets the value of the
474761f14bca Initial load
duke
parents:
diff changeset
   304
     * <code>Content-Type</code> header to the value contained in
474761f14bca Initial load
duke
parents:
diff changeset
   305
     * <code>contentType</code>, This method would first decode the base64
474761f14bca Initial load
duke
parents:
diff changeset
   306
     * input and write the resulting raw bytes to the attachment.
474761f14bca Initial load
duke
parents:
diff changeset
   307
     * <P>
474761f14bca Initial load
duke
parents:
diff changeset
   308
     *  A subsequent call to getSize() may not be an exact measure
474761f14bca Initial load
duke
parents:
diff changeset
   309
     *  of the content size.
474761f14bca Initial load
duke
parents:
diff changeset
   310
     *
474761f14bca Initial load
duke
parents:
diff changeset
   311
     * @param content the base64 encoded data to add to the attachment part
474761f14bca Initial load
duke
parents:
diff changeset
   312
     * @param contentType the value to set into the <code>Content-Type</code>
474761f14bca Initial load
duke
parents:
diff changeset
   313
     * header
474761f14bca Initial load
duke
parents:
diff changeset
   314
     *
474761f14bca Initial load
duke
parents:
diff changeset
   315
     * @exception SOAPException if an there is an error in setting the content
474761f14bca Initial load
duke
parents:
diff changeset
   316
     * @exception NullPointerException if <code>content</code> is null
474761f14bca Initial load
duke
parents:
diff changeset
   317
     *
474761f14bca Initial load
duke
parents:
diff changeset
   318
     * @since SAAJ 1.3
474761f14bca Initial load
duke
parents:
diff changeset
   319
     */
474761f14bca Initial load
duke
parents:
diff changeset
   320
    public abstract void setBase64Content(
474761f14bca Initial load
duke
parents:
diff changeset
   321
        InputStream content, String contentType) throws SOAPException;
474761f14bca Initial load
duke
parents:
diff changeset
   322
474761f14bca Initial load
duke
parents:
diff changeset
   323
474761f14bca Initial load
duke
parents:
diff changeset
   324
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   325
     * Gets the <code>DataHandler</code> object for this <code>AttachmentPart</code>
474761f14bca Initial load
duke
parents:
diff changeset
   326
     * object.
474761f14bca Initial load
duke
parents:
diff changeset
   327
     *
474761f14bca Initial load
duke
parents:
diff changeset
   328
     * @return the <code>DataHandler</code> object associated with this
474761f14bca Initial load
duke
parents:
diff changeset
   329
     *         <code>AttachmentPart</code> object
474761f14bca Initial load
duke
parents:
diff changeset
   330
     *
474761f14bca Initial load
duke
parents:
diff changeset
   331
     * @exception SOAPException if there is no data in
474761f14bca Initial load
duke
parents:
diff changeset
   332
     * this <code>AttachmentPart</code> object
474761f14bca Initial load
duke
parents:
diff changeset
   333
     */
474761f14bca Initial load
duke
parents:
diff changeset
   334
    public abstract DataHandler getDataHandler()
474761f14bca Initial load
duke
parents:
diff changeset
   335
        throws SOAPException;
474761f14bca Initial load
duke
parents:
diff changeset
   336
474761f14bca Initial load
duke
parents:
diff changeset
   337
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   338
     * Sets the given <code>DataHandler</code> object as the data handler
474761f14bca Initial load
duke
parents:
diff changeset
   339
     * for this <code>AttachmentPart</code> object. Typically, on an incoming
474761f14bca Initial load
duke
parents:
diff changeset
   340
     * message, the data handler is automatically set. When
474761f14bca Initial load
duke
parents:
diff changeset
   341
     * a message is being created and populated with content, the
474761f14bca Initial load
duke
parents:
diff changeset
   342
     * <code>setDataHandler</code> method can be used to get data from
474761f14bca Initial load
duke
parents:
diff changeset
   343
     * various data sources into the message.
474761f14bca Initial load
duke
parents:
diff changeset
   344
     *
474761f14bca Initial load
duke
parents:
diff changeset
   345
     * @param dataHandler the <code>DataHandler</code> object to be set
474761f14bca Initial load
duke
parents:
diff changeset
   346
     *
474761f14bca Initial load
duke
parents:
diff changeset
   347
     * @exception IllegalArgumentException if there was a problem with
474761f14bca Initial load
duke
parents:
diff changeset
   348
     *            the specified <code>DataHandler</code> object
474761f14bca Initial load
duke
parents:
diff changeset
   349
     */
474761f14bca Initial load
duke
parents:
diff changeset
   350
    public abstract void setDataHandler(DataHandler dataHandler);
474761f14bca Initial load
duke
parents:
diff changeset
   351
474761f14bca Initial load
duke
parents:
diff changeset
   352
474761f14bca Initial load
duke
parents:
diff changeset
   353
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   354
     * Gets the value of the MIME header whose name is "Content-ID".
474761f14bca Initial load
duke
parents:
diff changeset
   355
     *
474761f14bca Initial load
duke
parents:
diff changeset
   356
     * @return a <code>String</code> giving the value of the
474761f14bca Initial load
duke
parents:
diff changeset
   357
     *          "Content-ID" header or <code>null</code> if there
474761f14bca Initial load
duke
parents:
diff changeset
   358
     *          is none
474761f14bca Initial load
duke
parents:
diff changeset
   359
     * @see #setContentId
474761f14bca Initial load
duke
parents:
diff changeset
   360
     */
474761f14bca Initial load
duke
parents:
diff changeset
   361
    public String getContentId() {
474761f14bca Initial load
duke
parents:
diff changeset
   362
        String[] values = getMimeHeader("Content-ID");
474761f14bca Initial load
duke
parents:
diff changeset
   363
        if (values != null && values.length > 0)
474761f14bca Initial load
duke
parents:
diff changeset
   364
            return values[0];
474761f14bca Initial load
duke
parents:
diff changeset
   365
        return null;
474761f14bca Initial load
duke
parents:
diff changeset
   366
    }
474761f14bca Initial load
duke
parents:
diff changeset
   367
474761f14bca Initial load
duke
parents:
diff changeset
   368
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   369
     * Gets the value of the MIME header whose name is "Content-Location".
474761f14bca Initial load
duke
parents:
diff changeset
   370
     *
474761f14bca Initial load
duke
parents:
diff changeset
   371
     * @return a <code>String</code> giving the value of the
474761f14bca Initial load
duke
parents:
diff changeset
   372
     *          "Content-Location" header or <code>null</code> if there
474761f14bca Initial load
duke
parents:
diff changeset
   373
     *          is none
474761f14bca Initial load
duke
parents:
diff changeset
   374
     */
474761f14bca Initial load
duke
parents:
diff changeset
   375
    public String getContentLocation() {
474761f14bca Initial load
duke
parents:
diff changeset
   376
        String[] values = getMimeHeader("Content-Location");
474761f14bca Initial load
duke
parents:
diff changeset
   377
        if (values != null && values.length > 0)
474761f14bca Initial load
duke
parents:
diff changeset
   378
            return values[0];
474761f14bca Initial load
duke
parents:
diff changeset
   379
        return null;
474761f14bca Initial load
duke
parents:
diff changeset
   380
    }
474761f14bca Initial load
duke
parents:
diff changeset
   381
474761f14bca Initial load
duke
parents:
diff changeset
   382
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   383
     * Gets the value of the MIME header whose name is "Content-Type".
474761f14bca Initial load
duke
parents:
diff changeset
   384
     *
474761f14bca Initial load
duke
parents:
diff changeset
   385
     * @return a <code>String</code> giving the value of the
474761f14bca Initial load
duke
parents:
diff changeset
   386
     *          "Content-Type" header or <code>null</code> if there
474761f14bca Initial load
duke
parents:
diff changeset
   387
     *          is none
474761f14bca Initial load
duke
parents:
diff changeset
   388
     */
474761f14bca Initial load
duke
parents:
diff changeset
   389
    public String getContentType() {
474761f14bca Initial load
duke
parents:
diff changeset
   390
        String[] values = getMimeHeader("Content-Type");
474761f14bca Initial load
duke
parents:
diff changeset
   391
        if (values != null && values.length > 0)
474761f14bca Initial load
duke
parents:
diff changeset
   392
            return values[0];
474761f14bca Initial load
duke
parents:
diff changeset
   393
        return null;
474761f14bca Initial load
duke
parents:
diff changeset
   394
    }
474761f14bca Initial load
duke
parents:
diff changeset
   395
474761f14bca Initial load
duke
parents:
diff changeset
   396
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   397
     * Sets the MIME header whose name is "Content-ID" with the given value.
474761f14bca Initial load
duke
parents:
diff changeset
   398
     *
474761f14bca Initial load
duke
parents:
diff changeset
   399
     * @param contentId a <code>String</code> giving the value of the
474761f14bca Initial load
duke
parents:
diff changeset
   400
     *          "Content-ID" header
474761f14bca Initial load
duke
parents:
diff changeset
   401
     *
474761f14bca Initial load
duke
parents:
diff changeset
   402
     * @exception IllegalArgumentException if there was a problem with
474761f14bca Initial load
duke
parents:
diff changeset
   403
     *            the specified <code>contentId</code> value
474761f14bca Initial load
duke
parents:
diff changeset
   404
     * @see #getContentId
474761f14bca Initial load
duke
parents:
diff changeset
   405
     */
474761f14bca Initial load
duke
parents:
diff changeset
   406
    public void setContentId(String contentId)
474761f14bca Initial load
duke
parents:
diff changeset
   407
    {
474761f14bca Initial load
duke
parents:
diff changeset
   408
        setMimeHeader("Content-ID", contentId);
474761f14bca Initial load
duke
parents:
diff changeset
   409
    }
474761f14bca Initial load
duke
parents:
diff changeset
   410
474761f14bca Initial load
duke
parents:
diff changeset
   411
474761f14bca Initial load
duke
parents:
diff changeset
   412
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   413
     * Sets the MIME header whose name is "Content-Location" with the given value.
474761f14bca Initial load
duke
parents:
diff changeset
   414
     *
474761f14bca Initial load
duke
parents:
diff changeset
   415
     *
474761f14bca Initial load
duke
parents:
diff changeset
   416
     * @param contentLocation a <code>String</code> giving the value of the
474761f14bca Initial load
duke
parents:
diff changeset
   417
     *          "Content-Location" header
474761f14bca Initial load
duke
parents:
diff changeset
   418
     * @exception IllegalArgumentException if there was a problem with
474761f14bca Initial load
duke
parents:
diff changeset
   419
     *            the specified content location
474761f14bca Initial load
duke
parents:
diff changeset
   420
     */
474761f14bca Initial load
duke
parents:
diff changeset
   421
    public void setContentLocation(String contentLocation)
474761f14bca Initial load
duke
parents:
diff changeset
   422
    {
474761f14bca Initial load
duke
parents:
diff changeset
   423
        setMimeHeader("Content-Location", contentLocation);
474761f14bca Initial load
duke
parents:
diff changeset
   424
    }
474761f14bca Initial load
duke
parents:
diff changeset
   425
474761f14bca Initial load
duke
parents:
diff changeset
   426
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   427
     * Sets the MIME header whose name is "Content-Type" with the given value.
474761f14bca Initial load
duke
parents:
diff changeset
   428
     *
474761f14bca Initial load
duke
parents:
diff changeset
   429
     * @param contentType a <code>String</code> giving the value of the
474761f14bca Initial load
duke
parents:
diff changeset
   430
     *          "Content-Type" header
474761f14bca Initial load
duke
parents:
diff changeset
   431
     *
474761f14bca Initial load
duke
parents:
diff changeset
   432
     * @exception IllegalArgumentException if there was a problem with
474761f14bca Initial load
duke
parents:
diff changeset
   433
     *            the specified content type
474761f14bca Initial load
duke
parents:
diff changeset
   434
     */
474761f14bca Initial load
duke
parents:
diff changeset
   435
    public void setContentType(String contentType)
474761f14bca Initial load
duke
parents:
diff changeset
   436
    {
474761f14bca Initial load
duke
parents:
diff changeset
   437
        setMimeHeader("Content-Type", contentType);
474761f14bca Initial load
duke
parents:
diff changeset
   438
    }
474761f14bca Initial load
duke
parents:
diff changeset
   439
474761f14bca Initial load
duke
parents:
diff changeset
   440
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   441
     * Removes all MIME headers that match the given name.
474761f14bca Initial load
duke
parents:
diff changeset
   442
     *
474761f14bca Initial load
duke
parents:
diff changeset
   443
     * @param header the string name of the MIME header/s to
474761f14bca Initial load
duke
parents:
diff changeset
   444
     *               be removed
474761f14bca Initial load
duke
parents:
diff changeset
   445
     */
474761f14bca Initial load
duke
parents:
diff changeset
   446
    public abstract void removeMimeHeader(String header);
474761f14bca Initial load
duke
parents:
diff changeset
   447
474761f14bca Initial load
duke
parents:
diff changeset
   448
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   449
     * Removes all the MIME header entries.
474761f14bca Initial load
duke
parents:
diff changeset
   450
     */
474761f14bca Initial load
duke
parents:
diff changeset
   451
    public abstract void removeAllMimeHeaders();
474761f14bca Initial load
duke
parents:
diff changeset
   452
474761f14bca Initial load
duke
parents:
diff changeset
   453
474761f14bca Initial load
duke
parents:
diff changeset
   454
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   455
     * Gets all the values of the header identified by the given
474761f14bca Initial load
duke
parents:
diff changeset
   456
     * <code>String</code>.
474761f14bca Initial load
duke
parents:
diff changeset
   457
     *
474761f14bca Initial load
duke
parents:
diff changeset
   458
     * @param name the name of the header; example: "Content-Type"
474761f14bca Initial load
duke
parents:
diff changeset
   459
     * @return a <code>String</code> array giving the value for the
474761f14bca Initial load
duke
parents:
diff changeset
   460
     *         specified header
474761f14bca Initial load
duke
parents:
diff changeset
   461
     * @see #setMimeHeader
474761f14bca Initial load
duke
parents:
diff changeset
   462
     */
474761f14bca Initial load
duke
parents:
diff changeset
   463
    public abstract String[] getMimeHeader(String name);
474761f14bca Initial load
duke
parents:
diff changeset
   464
474761f14bca Initial load
duke
parents:
diff changeset
   465
474761f14bca Initial load
duke
parents:
diff changeset
   466
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   467
     * Changes the first header entry that matches the given name
474761f14bca Initial load
duke
parents:
diff changeset
   468
     * to the given value, adding a new header if no existing header
474761f14bca Initial load
duke
parents:
diff changeset
   469
     * matches. This method also removes all matching headers but the first. <p>
474761f14bca Initial load
duke
parents:
diff changeset
   470
     *
474761f14bca Initial load
duke
parents:
diff changeset
   471
     * Note that RFC822 headers can only contain US-ASCII characters.
474761f14bca Initial load
duke
parents:
diff changeset
   472
     *
474761f14bca Initial load
duke
parents:
diff changeset
   473
     * @param   name    a <code>String</code> giving the name of the header
474761f14bca Initial load
duke
parents:
diff changeset
   474
     *                  for which to search
474761f14bca Initial load
duke
parents:
diff changeset
   475
     * @param   value   a <code>String</code> giving the value to be set for
474761f14bca Initial load
duke
parents:
diff changeset
   476
     *                  the header whose name matches the given name
474761f14bca Initial load
duke
parents:
diff changeset
   477
     *
474761f14bca Initial load
duke
parents:
diff changeset
   478
     * @exception IllegalArgumentException if there was a problem with
474761f14bca Initial load
duke
parents:
diff changeset
   479
     *            the specified mime header name or value
474761f14bca Initial load
duke
parents:
diff changeset
   480
     */
474761f14bca Initial load
duke
parents:
diff changeset
   481
    public abstract void setMimeHeader(String name, String value);
474761f14bca Initial load
duke
parents:
diff changeset
   482
474761f14bca Initial load
duke
parents:
diff changeset
   483
474761f14bca Initial load
duke
parents:
diff changeset
   484
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   485
     * Adds a MIME header with the specified name and value to this
474761f14bca Initial load
duke
parents:
diff changeset
   486
     * <code>AttachmentPart</code> object.
474761f14bca Initial load
duke
parents:
diff changeset
   487
     * <p>
474761f14bca Initial load
duke
parents:
diff changeset
   488
     * Note that RFC822 headers can contain only US-ASCII characters.
474761f14bca Initial load
duke
parents:
diff changeset
   489
     *
474761f14bca Initial load
duke
parents:
diff changeset
   490
     * @param   name    a <code>String</code> giving the name of the header
474761f14bca Initial load
duke
parents:
diff changeset
   491
     *                  to be added
474761f14bca Initial load
duke
parents:
diff changeset
   492
     * @param   value   a <code>String</code> giving the value of the header
474761f14bca Initial load
duke
parents:
diff changeset
   493
     *                  to be added
474761f14bca Initial load
duke
parents:
diff changeset
   494
     *
474761f14bca Initial load
duke
parents:
diff changeset
   495
     * @exception IllegalArgumentException if there was a problem with
474761f14bca Initial load
duke
parents:
diff changeset
   496
     *            the specified mime header name or value
474761f14bca Initial load
duke
parents:
diff changeset
   497
     */
474761f14bca Initial load
duke
parents:
diff changeset
   498
    public abstract void addMimeHeader(String name, String value);
474761f14bca Initial load
duke
parents:
diff changeset
   499
474761f14bca Initial load
duke
parents:
diff changeset
   500
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   501
     * Retrieves all the headers for this <code>AttachmentPart</code> object
474761f14bca Initial load
duke
parents:
diff changeset
   502
     * as an iterator over the <code>MimeHeader</code> objects.
474761f14bca Initial load
duke
parents:
diff changeset
   503
     *
474761f14bca Initial load
duke
parents:
diff changeset
   504
     * @return  an <code>Iterator</code> object with all of the Mime
474761f14bca Initial load
duke
parents:
diff changeset
   505
     *          headers for this <code>AttachmentPart</code> object
474761f14bca Initial load
duke
parents:
diff changeset
   506
     */
474761f14bca Initial load
duke
parents:
diff changeset
   507
    public abstract Iterator getAllMimeHeaders();
474761f14bca Initial load
duke
parents:
diff changeset
   508
474761f14bca Initial load
duke
parents:
diff changeset
   509
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   510
     * Retrieves all <code>MimeHeader</code> objects that match a name in
474761f14bca Initial load
duke
parents:
diff changeset
   511
     * the given array.
474761f14bca Initial load
duke
parents:
diff changeset
   512
     *
474761f14bca Initial load
duke
parents:
diff changeset
   513
     * @param names a <code>String</code> array with the name(s) of the
474761f14bca Initial load
duke
parents:
diff changeset
   514
     *        MIME headers to be returned
474761f14bca Initial load
duke
parents:
diff changeset
   515
     * @return  all of the MIME headers that match one of the names in the
474761f14bca Initial load
duke
parents:
diff changeset
   516
     *           given array as an <code>Iterator</code> object
474761f14bca Initial load
duke
parents:
diff changeset
   517
     */
474761f14bca Initial load
duke
parents:
diff changeset
   518
    public abstract Iterator getMatchingMimeHeaders(String[] names);
474761f14bca Initial load
duke
parents:
diff changeset
   519
474761f14bca Initial load
duke
parents:
diff changeset
   520
    /**
474761f14bca Initial load
duke
parents:
diff changeset
   521
     * Retrieves all <code>MimeHeader</code> objects whose name does
474761f14bca Initial load
duke
parents:
diff changeset
   522
     * not match a name in the given array.
474761f14bca Initial load
duke
parents:
diff changeset
   523
     *
474761f14bca Initial load
duke
parents:
diff changeset
   524
     * @param names a <code>String</code> array with the name(s) of the
474761f14bca Initial load
duke
parents:
diff changeset
   525
     *        MIME headers not to be returned
474761f14bca Initial load
duke
parents:
diff changeset
   526
     * @return  all of the MIME headers in this <code>AttachmentPart</code> object
474761f14bca Initial load
duke
parents:
diff changeset
   527
     *          except those that match one of the names in the
474761f14bca Initial load
duke
parents:
diff changeset
   528
     *           given array.  The nonmatching MIME headers are returned as an
474761f14bca Initial load
duke
parents:
diff changeset
   529
     *           <code>Iterator</code> object.
474761f14bca Initial load
duke
parents:
diff changeset
   530
     */
474761f14bca Initial load
duke
parents:
diff changeset
   531
    public abstract Iterator getNonMatchingMimeHeaders(String[] names);
474761f14bca Initial load
duke
parents:
diff changeset
   532
}