You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jb...@apache.org on 2005/02/01 02:07:44 UTC

svn commit: r149344 - geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimePartDataSource.java

Author: jboynes
Date: Mon Jan 31 17:07:44 2005
New Revision: 149344

URL: http://svn.apache.org/viewcvs?view=rev&rev=149344
Log:
cleanup

Modified:
    geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimePartDataSource.java

Modified: geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimePartDataSource.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimePartDataSource.java?view=diff&r1=149343&r2=149344
==============================================================================
--- geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimePartDataSource.java (original)
+++ geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimePartDataSource.java Mon Jan 31 17:07:44 2005
@@ -30,46 +30,46 @@
  * @version $Rev$ $Date$
  */
 public class MimePartDataSource implements DataSource, MessageAware {
-    private MimePart _part;
+    private final MimePart part;
 
     public MimePartDataSource(MimePart part) {
-        _part = part;
-    }
-
-    public String getContentType() {
-        try {
-            return _part.getContentType();
-        } catch (MessagingException e) {
-            throw new RuntimeException(e);
-        }
+        this.part = part;
     }
 
     public InputStream getInputStream() throws IOException {
-        InputStream content;
         try {
-            String encoding = _part.getEncoding();
-            if (_part instanceof MimeMessage) {
-                content = ((MimeMessage) _part).getContentStream();
-            } else if (_part instanceof MimeBodyPart) {
-                content = ((MimeBodyPart) _part).getContentStream();
+            InputStream stream;
+            if (part instanceof MimeMessage) {
+                stream = ((MimeMessage) part).getContentStream();
+            } else if (part instanceof MimeBodyPart) {
+                stream = ((MimeBodyPart) part).getContentStream();
             } else {
                 throw new MessagingException("Unknown part");
             }
-            return MimeUtility.decode(content, encoding);
+            String encoding = part.getEncoding();
+            return encoding == null ? stream : MimeUtility.decode(stream, encoding);
         } catch (MessagingException e) {
-            throw new IOException(e.toString());
+            throw (IOException) new IOException(e.getMessage()).initCause(e);
         }
     }
 
-    public synchronized MessageContext getMessageContext() {
-        return new MessageContext(_part);
+    public OutputStream getOutputStream() throws IOException {
+        throw new UnknownServiceException();
+    }
+
+    public String getContentType() {
+        try {
+            return part.getContentType();
+        } catch (MessagingException e) {
+            return null;
+        }
     }
 
     public String getName() {
         return "";
     }
 
-    public OutputStream getOutputStream() throws IOException {
-        throw new UnknownServiceException();
+    public synchronized MessageContext getMessageContext() {
+        return new MessageContext(part);
     }
 }