Class MimePartDataSource

  • All Implemented Interfaces:
    DataSource

    public final class MimePartDataSource
    extends Object
    implements DataSource
    A utility class that implements a DataSource out of a MimeBodyPart. This class is primarily meant for service providers.
    Author:
    John Mani
    • Constructor Detail

      • MimePartDataSource

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

      • 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 DataSource
        Returns:
        decoded input stream
        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 DataSource
      • getName

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

        This implementation just returns an empty string.

        Specified by:
        getName in interface DataSource