< prev index next >

jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/packaging/mime/internet/MimeBodyPart.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
*** 30,40 **** package com.sun.xml.internal.messaging.saaj.packaging.mime.internet; - import com.sun.xml.internal.messaging.saaj.packaging.mime.Header; import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException; import com.sun.xml.internal.messaging.saaj.packaging.mime.util.OutputUtil; import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; import com.sun.xml.internal.messaging.saaj.util.FinalArrayList; --- 30,39 ----
*** 50,65 **** import com.sun.xml.internal.org.jvnet.mimepull.MIMEPart; /** * This class represents a MIME body part. * MimeBodyParts are contained in <code>MimeMultipart</code> ! * objects. <p> ! * * MimeBodyPart uses the <code>InternetHeaders</code> class to parse ! * and store the headers of that body part. <p> * ! * <hr><strong>A note on RFC 822 and MIME headers</strong><p> * * RFC 822 header fields <strong>must</strong> contain only * US-ASCII characters. MIME allows non ASCII characters to be present * in certain portions of certain headers, by encoding those characters. * RFC 2047 specifies the rules for doing this. The MimeUtility --- 49,64 ---- import com.sun.xml.internal.org.jvnet.mimepull.MIMEPart; /** * This class represents a MIME body part. * MimeBodyParts are contained in <code>MimeMultipart</code> ! * objects. ! * <p> * MimeBodyPart uses the <code>InternetHeaders</code> class to parse ! * and store the headers of that body part. * ! * <hr><strong>A note on RFC 822 and MIME headers</strong> * * RFC 822 header fields <strong>must</strong> contain only * US-ASCII characters. MIME allows non ASCII characters to be present * in certain portions of certain headers, by encoding those characters. * RFC 2047 specifies the rules for doing this. The MimeUtility
*** 68,78 **** * <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 */ --- 67,77 ---- * <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 */
*** 177,186 **** --- 176,187 ---- * is that the MimeMultipart parser will extract each body part's bytes * from a multipart stream and feed them into this constructor, without * the delimiter strings. * * @param is the body part Input Stream + * + * @exception MessagingException in case of error */ public MimeBodyPart(InputStream is) throws MessagingException { if (!(is instanceof ByteArrayInputStream) && !(is instanceof BufferedInputStream) && !(is instanceof SharedInputStream))
*** 214,223 **** --- 215,225 ---- * * Used by providers. * * @param headers The header of this part * @param content bytes representing the body of this part. + * @param len content length. */ public MimeBodyPart(InternetHeaders headers, byte[] content, int len) { this.headers = headers; this.content = content; this.contentLength = len;
*** 240,249 **** --- 242,252 ---- } } /** * Return the containing <code>MimeMultipart</code> object, * or <code>null</code> if not known. + * @return parent part. */ public MimeMultipart getParent() { return parent; }
*** 251,260 **** --- 254,264 ---- * Set the parent of this <code>MimeBodyPart</code> to be the specified * <code>MimeMultipart</code>. Normally called by <code>MimeMultipart</code>'s * <code>addBodyPart</code> method. <code>parent</code> may be * <code>null</code> if the <code>MimeBodyPart</code> is being removed * from its containing <code>MimeMultipart</code>. + * @param parent parent part * @since JavaMail 1.1 */ public void setParent(MimeMultipart parent) { this.parent = parent; }
*** 349,358 **** --- 353,365 ---- * with <strong>"text/plain; charset=foobar"</strong>. <p> * * If the <code>subType</code> of <code>mimeType</code> is the * special character '*', then the subtype is ignored during the * comparison. + * + * @param mimeType string + * @return true if it is valid mime type */ public boolean isMimeType(String mimeType) { boolean result; // XXX - lots of room for optimization here! try {
*** 373,382 **** --- 380,392 ---- * null is returned. <p> * * This implementation uses <code>getHeader(name)</code> * to obtain the requisite header field. * + * @return content disposition + * @exception MessagingException in case of error + * * @see #headers */ public String getDisposition() throws MessagingException { String s = getHeader("Content-Disposition", null);
*** 390,399 **** --- 400,412 ---- /** * Set the "Content-Disposition" header field of this body part. * If the disposition is null, any existing "Content-Disposition" * header field is removed. * + * @param disposition value + * + * @exception MessagingException in case of error * @exception IllegalStateException if this body part is * obtained from a READ_ONLY folder. */ public void setDisposition(String disposition) throws MessagingException { if (disposition == null)
*** 421,430 **** --- 434,446 ---- * or its value is absent. <p> * * This implementation uses <code>getHeader(name)</code> * to obtain the requisite header field. * + * @return encoding + * @exception MessagingException in case of error + * * @see #headers */ public String getEncoding() throws MessagingException { String s = getHeader("Content-Transfer-Encoding", null);
*** 463,482 **** --- 479,501 ---- * <code>null</code> if the field is unavailable or its value is * absent. <p> * * This implementation uses <code>getHeader(name)</code> * to obtain the requisite header field. + * + * @return conent id */ public String getContentID() { return getHeader("Content-ID", null); } /** * Set the "Content-ID" header field of this body part. * If the <code>cid</code> parameter is null, any existing * "Content-ID" is removed. * + * @param cid content id * @exception IllegalStateException if this body part is * obtained from a READ_ONLY folder. * @since JavaMail 1.3 */ public void setContentID(String cid) {
*** 491,508 **** --- 510,531 ---- * <code>null</code> if this field is unavailable or its value * is absent. <p> * * This implementation uses <code>getHeader(name)</code> * to obtain the requisite header field. + * + * @return content MD5 sum */ public String getContentMD5() { return getHeader("Content-MD5", null); } /** * Set the "Content-MD5" header field of this body part. * + * @param md5 content md5 sum + * * @exception IllegalStateException if this body part is * obtained from a READ_ONLY folder. */ public void setContentMD5(String md5) { setHeader("Content-MD5", md5);
*** 514,523 **** --- 537,549 ---- * RFC 1766. Returns <code>null</code> if this header is not * available or its value is absent. <p> * * This implementation uses <code>getHeader(name)</code> * to obtain the requisite header field. + * + * @return array of language tags + * @exception MessagingException in case of error */ public String[] getContentLanguage() throws MessagingException { String s = getHeader("Content-Language", null); if (s == null)
*** 661,670 **** --- 687,697 ---- * not available, returns the value of the "name" parameter from * the "Content-Type" header field of this body part. * Returns <code>null</code> if both are absent. * * @return filename + * @exception MessagingException in case of error */ public String getFileName() throws MessagingException { String filename = null; String s = getHeader("Content-Disposition", null);
*** 690,699 **** --- 717,729 ---- * Set the filename associated with this body part, if possible. <p> * * Sets the "filename" parameter of the "Content-Disposition" * header field of this body part. * + * @param filename filename + * + * @exception MessagingException in case of error * @exception IllegalStateException if this body part is * obtained from a READ_ONLY folder. */ public void setFileName(String filename) throws MessagingException { // Set the Content-Disposition "filename" parameter
*** 767,807 **** --- 797,848 ---- * use this method and attempt to decode the raw data itself. <p> * * This implementation simply calls the <code>getContentStream</code> * method. * + * @return input stream + * + * @exception MessagingException in case of error + * * @see #getInputStream * @see #getContentStream * @since JavaMail 1.2 + * */ public InputStream getRawInputStream() throws MessagingException { return getContentStream(); } /** * Return a DataHandler for this body part's content. <p> * * The implementation provided here works just like the * the implementation in MimeMessage. + * + * @return data handler */ public DataHandler getDataHandler() { if (mimePart != null) { //return an inputstream return new DataHandler(new DataSource() { + @Override public InputStream getInputStream() throws IOException { return mimePart.read(); } + @Override public OutputStream getOutputStream() throws IOException { throw new UnsupportedOperationException("getOutputStream cannot be supported : You have enabled LazyAttachments Option"); } + @Override public String getContentType() { return mimePart.getContentType(); } + @Override public String getName() { return "MIMEPart Wrapped DataSource"; } }); }
*** 888,897 **** --- 929,940 ---- * to scan all the characters to determine what charset to * use. <p> * If the charset is already known, use the * setText() version that takes the charset parameter. * + * @param text string + * * @see #setText(String text, String charset) */ public void setText(String text) { setText(text, null); }
*** 900,909 **** --- 943,955 ---- * Convenience method that sets the given String as this part's * content, with a MIME type of "text/plain" and the specified * charset. The given Unicode string will be charset-encoded * using the specified charset. The charset is also used to set * the "charset" parameter. + * + * @param text string + * @param charset character set */ public void setText(String text, String charset) { if (charset == null) { if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII) charset = MimeUtility.getDefaultMIMECharset();
*** 930,940 **** } /** * Output the body part as an RFC 822 format stream. * ! * @exception MessagingException * @exception IOException if an error occurs writing to the * stream or if an error is generated * by the javax.activation layer. * @see DataHandler#writeTo */ --- 976,988 ---- } /** * Output the body part as an RFC 822 format stream. * ! * @param os output stream ! * ! * @exception MessagingException in case of error * @exception IOException if an error occurs writing to the * stream or if an error is generated * by the javax.activation layer. * @see DataHandler#writeTo */
*** 1031,1056 **** headers.addHeader(name, value); } /** * Remove all headers with this name. */ public void removeHeader(String name) { headers.removeHeader(name); } /** * Return all the headers from this Message as an Enumeration of * Header objects. */ ! public List<? extends Header> getAllHeaders() { return headers.getAllHeaders(); } /** * Add a header line to this body part */ public void addHeaderLine(String line) { headers.addHeaderLine(line); } --- 1079,1110 ---- headers.addHeader(name, value); } /** * Remove all headers with this name. + * + * @param name header name */ public void removeHeader(String name) { headers.removeHeader(name); } /** * Return all the headers from this Message as an Enumeration of * Header objects. + * + * @return all headers */ ! public FinalArrayList<hdr> getAllHeaders() { return headers.getAllHeaders(); } /** * Add a header line to this body part + * + * @param line header line to add */ public void addHeaderLine(String line) { headers.addHeaderLine(line); }
*** 1073,1082 **** --- 1127,1138 ---- * need to resync our headers. * * <br> * In both cases this method is typically called by the * <code>Message.saveChanges</code> method. + * + * @exception MessagingException in case of error. */ protected void updateHeaders() throws MessagingException { DataHandler dh = getDataHandler(); /* * Code flow indicates null is never returned from
< prev index next >