com.sun.xml.messaging.saaj.packaging.mime.internet
Class MimePartDataSource

java.lang.Object
  extended by com.sun.xml.messaging.saaj.packaging.mime.internet.MimePartDataSource
All Implemented Interfaces:
javax.activation.DataSource

public final class MimePartDataSource
extends java.lang.Object
implements javax.activation.DataSource

A utility class that implements a DataSource out of a MimeBodyPart. This class is primarily meant for service providers.


Constructor Summary
MimePartDataSource(MimeBodyPart part)
          Constructor, that constructs a DataSource from a MimeBodyPart.
 
Method Summary
 java.lang.String getContentType()
          Returns the content-type of this DataSource.
 java.io.InputStream getInputStream()
          Returns an input stream from this MimeBodyPart.
 java.lang.String getName()
          DataSource method to return a name.
 java.io.OutputStream getOutputStream()
          DataSource method to return an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimePartDataSource

public MimePartDataSource(MimeBodyPart part)
Constructor, that constructs a DataSource from a MimeBodyPart.

Method Detail

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an input stream from this MimeBodyPart.

This method applies the appropriate transfer-decoding, based on the Content-Transfer-Encoding attribute of this MimeBodyPart. Thus the returned input stream is a decoded stream of bytes.

This implementation obtains the raw content from the MimeBodyPart using the getContentStream() method and decodes it using the MimeUtility.decode() method.

Specified by:
getInputStream in interface javax.activation.DataSource
Returns:
decoded input stream
Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
DataSource method to return an output stream.

This implementation throws the UnknownServiceException.

Specified by:
getOutputStream in interface javax.activation.DataSource
Throws:
java.io.IOException

getContentType

public java.lang.String getContentType()
Returns the content-type of this DataSource.

This implementation just invokes the getContentType method on the MimeBodyPart.

Specified by:
getContentType in interface javax.activation.DataSource

getName

public java.lang.String getName()
DataSource method to return a name.

This implementation just returns an empty string.

Specified by:
getName in interface javax.activation.DataSource