Class ByteArrayAttachment

java.lang.Object
de.aristaflow.adept2.model.mail.SerialisableAttachment
de.aristaflow.adept2.model.mail.ByteArrayAttachment
All Implemented Interfaces:
Closeable, Serializable, AutoCloseable

public class ByteArrayAttachment extends SerialisableAttachment
A SerialisableAttachment having plain byte[] content.
See Also:
  • Field Details

    • bytes

      protected final byte[] bytes
      The content represented as byte[].
  • Constructor Details

    • ByteArrayAttachment

      public ByteArrayAttachment(String name, String description, byte[] bytes)
      Creates an attachment having the designated name, description and content. The content type is set to "application/octet-stream".
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      bytes - The content of the attachment represented as byte[].
    • ByteArrayAttachment

      public ByteArrayAttachment(String name, String description, byte[] bytes, boolean inline)
      Creates an attachment having the designated name, description and content. The content type is set to "application/octet-stream".
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      bytes - The content of the attachment represented as byte[].
      inline - Whether to inline this attachment in case of an HTML message using the designated name.
    • ByteArrayAttachment

      public ByteArrayAttachment(String name, String description, byte[] bytes, String inlineName)
      Creates an attachment having the designated name, description and content. The content type is set to "application/octet-stream".
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      bytes - The content of the attachment represented as byte[].
      inlineName - The name used in the corresponding HTML message to refer to this attachment to be inlined. Use null to not inline the attachment.
    • ByteArrayAttachment

      public ByteArrayAttachment(String name, String description, String contentType, byte[] bytes)
      Creates an attachment having the designated name, description, content type (MIME) and content.
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      contentType - The content type (MIME) of the attachment.
      bytes - The content of the attachment represented as byte[].
    • ByteArrayAttachment

      public ByteArrayAttachment(String name, String description, String contentType, byte[] bytes, boolean inline)
      Creates an attachment having the designated name, description, content type (MIME) and content.
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      contentType - The content type (MIME) of the attachment.
      bytes - The content of the attachment represented as byte[].
      inline - Whether to inline this attachment in case of an HTML message using the designated name.
    • ByteArrayAttachment

      public ByteArrayAttachment(String name, String description, String contentType, byte[] bytes, String inlineName)
      Creates an attachment having the designated name, description, content type (MIME) and content.
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      contentType - The content type (MIME) of the attachment.
      bytes - The content of the attachment represented as byte[].
      inlineName - The name used in the corresponding HTML message to refer to this attachment to be inlined. Use null to not inline the attachment.
    • ByteArrayAttachment

      public ByteArrayAttachment(String name, String description, String contentType, InputStream content, String inlineName) throws IOException
      Creates an attachment having the designated name, description, content type (MIME) and content retrieved from the designated string.
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      contentType - The content type (MIME) of the attachment.
      content - The content of the attachment represented as InputStream. The stream will be closed after the creation.
      inlineName - The name used in the corresponding HTML message to refer to this attachment to be inlined. Use null to not inline the attachment.
      Throws:
      IOException - If there is a problem reading the content from the designated stream, an IOException will be thrown.
  • Method Details

    • getContent

      public InputStream getContent()
      Description copied from class: SerialisableAttachment
      Gets the content of the attachment represented as InputStream.
      Note that this should only be called by the receiving service since the InputStream cannot be serialised.
      Specified by:
      getContent in class SerialisableAttachment
      Returns:
      The actual data of the attachment. The caller is responsible for closing.