Class ByteArrayDataSource

java.lang.Object
com.priint.pubserver.util.ByteArrayDataSource
All Implemented Interfaces:
jakarta.activation.DataSource

public class ByteArrayDataSource extends Object implements jakarta.activation.DataSource
Class responsible for ByteArrayDataSource
  • Constructor Details

    • ByteArrayDataSource

      public ByteArrayDataSource()
      default empty constructor
    • ByteArrayDataSource

      public ByteArrayDataSource(String contentType, 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(String contentType, String name, 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 Details

    • getInputStream

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

      public OutputStream getOutputStream() throws IOException
      Specified by:
      getOutputStream in interface jakarta.activation.DataSource
      Returns:
      ByteArrayOutputStream
      Throws:
      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 String getName()
      Specified by:
      getName in interface jakarta.activation.DataSource
      Returns:
      name as String
    • setName

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

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

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