src/share/jaxws_classes/javax/xml/soap/AttachmentPart.java

Fri, 04 Oct 2013 16:21:34 +0100

author
mkos
date
Fri, 04 Oct 2013 16:21:34 +0100
changeset 408
b0610cd08440
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8025054: Update JAX-WS RI integration to 2.2.9-b130926.1035
Reviewed-by: chegar

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

mercurial