Class ByteArrayDataSource

  • All Implemented Interfaces:
    javax.activation.DataSource

    public class ByteArrayDataSource
    extends java.lang.Object
    implements javax.activation.DataSource
    Class responsible for ByteArrayDataSource
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getContentType()  
      byte[] getData()  
      java.io.InputStream getInputStream()  
      java.lang.String getName()  
      java.io.OutputStream getOutputStream()  
      void setContentType​(java.lang.String contentType)
      set the content type of the ByteArrayDataSource
      void setData​(byte[] data)
      set the data for the ByteArrayDataSource
      void setName​(java.lang.String name)
      set the name for the ByteArrayDataSource
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteArrayDataSource

        public ByteArrayDataSource()
        default empty constructor
      • ByteArrayDataSource

        public ByteArrayDataSource​(java.lang.String contentType,
                                   java.lang.String name,
                                   byte[] data)
        constructor
        Parameters:
        contentType - type of content to be created
        name - name of the ByteArrayDataSource to be created
        data - data provided as byte[]
      • ByteArrayDataSource

        public ByteArrayDataSource​(java.lang.String contentType,
                                   java.lang.String name,
                                   java.lang.String data)
        constructor
        Parameters:
        contentType - type of content to be created
        name - name of the ByteArrayDataSource to be created
        data - data provided as String
      • ByteArrayDataSource

        public ByteArrayDataSource​(byte[] data)
        constructor. Content type is automatically set to "application/text". Name is set to "String"
        Parameters:
        data - data provided as byte[] to be included.
    • Method Detail

      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Specified by:
        getInputStream in interface javax.activation.DataSource
        Returns:
        ByteArrayInputStream
        Throws:
        java.io.IOException
      • getOutputStream

        public java.io.OutputStream getOutputStream()
                                             throws java.io.IOException
        Specified by:
        getOutputStream in interface javax.activation.DataSource
        Returns:
        ByteArrayOutputStream
        Throws:
        java.io.IOException
      • getData

        public byte[] getData()
        Returns:
        data as byte[]
      • setData

        public void setData​(byte[] data)
        set the data for the ByteArrayDataSource
        Parameters:
        data - as byte[]
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface javax.activation.DataSource
        Returns:
        name as String
      • setName

        public void setName​(java.lang.String name)
        set the name for the ByteArrayDataSource
        Parameters:
        name - as String
      • getContentType

        public java.lang.String getContentType()
        Specified by:
        getContentType in interface javax.activation.DataSource
        Returns:
        content type as String
      • setContentType

        public void setContentType​(java.lang.String contentType)
        set the content type of the ByteArrayDataSource
        Parameters:
        contentType - as String