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

public final class MimePartDataSource extends Object implements jakarta.activation.DataSource
A utility class that implements a DataSource out of a MimeBodyPart. This class is primarily meant for service providers.
  • Constructor Details

    • MimePartDataSource

      public MimePartDataSource(MimeBodyPart part)
      Constructor, that constructs a DataSource from a MimeBodyPart.
      Parameters:
      part - body part
  • Method Details

    • getInputStream

      public InputStream getInputStream() throws 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 jakarta.activation.DataSource
      Returns:
      decoded input stream
      Throws:
      IOException
    • getOutputStream

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

      This implementation throws the UnknownServiceException.

      Specified by:
      getOutputStream in interface jakarta.activation.DataSource
      Throws:
      IOException
    • getContentType

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

      This implementation just invokes the getContentType method on the MimeBodyPart.

      Specified by:
      getContentType in interface jakarta.activation.DataSource
    • getName

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

      This implementation just returns an empty string.

      Specified by:
      getName in interface jakarta.activation.DataSource