< 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 +1,7 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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,11 +30,10 @@
 
 
 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;
 

@@ -50,16 +49,16 @@
 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>
- *
+ * objects.
+ * <p>
  * MimeBodyPart uses the <code>InternetHeaders</code> class to parse
- * and store the headers of that body part. <p>
+ * and store the headers of that body part.
  *
- * <hr><strong>A note on RFC 822 and MIME headers</strong><p>
+ * <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,11 +67,11 @@
  * <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>
+ * responsible for folding and unfolding headers as appropriate.
  *
  * @author John Mani
  * @author Bill Shannon
  * @see MimeUtility
  */

@@ -177,10 +176,12 @@
      * 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,10 +215,11 @@
      *
      * 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,10 +242,11 @@
         }
     }
     /**
      * Return the containing <code>MimeMultipart</code> object,
      * or <code>null</code> if not known.
+     * @return parent part.
      */
     public MimeMultipart getParent() {
         return parent;
     }
 

@@ -251,10 +254,11 @@
      * 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,10 +353,13 @@
      * 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,10 +380,13 @@
      * 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,10 +400,13 @@
     /**
      * 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,10 +434,13 @@
      * 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,20 +479,23 @@
      * <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,18 +510,22 @@
      * <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,10 +537,13 @@
      * 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,10 +687,11 @@
      * 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,10 +717,13 @@
      * 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,41 +797,52 @@
      * 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,10 +929,12 @@
      * 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,10 +943,13 @@
      * 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,11 +976,13 @@
     }
 
     /**
      * Output the body part as an RFC 822 format stream.
      *
-     * @exception MessagingException
+     * @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,26 +1079,32 @@
         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 List<? extends Header> getAllHeaders() {
+    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,10 +1127,12 @@
      * 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 >