Package de.aristaflow.adept2.model.mail
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
ASerialisableAttachment
having plainbyte[]
content.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
bytes
The content represented asbyte[]
.-
Fields inherited from class de.aristaflow.adept2.model.mail.SerialisableAttachment
contentType, description, inlineName, name
-
-
Constructor Summary
Constructors Constructor Description ByteArrayAttachment(String name, String description, byte[] bytes)
Creates an attachment having the designated name, description and content.ByteArrayAttachment(String name, String description, byte[] bytes, boolean inline)
Creates an attachment having the designated name, description and content.ByteArrayAttachment(String name, String description, byte[] bytes, String inlineName)
Creates an attachment having the designated name, description and content.ByteArrayAttachment(String name, String description, String contentType, byte[] bytes)
Creates an attachment having the designated name, description, content type (MIME) and content.ByteArrayAttachment(String name, String description, String contentType, byte[] bytes, boolean inline)
Creates an attachment having the designated name, description, content type (MIME) and content.ByteArrayAttachment(String name, String description, String contentType, byte[] bytes, String inlineName)
Creates an attachment having the designated name, description, content type (MIME) and content.ByteArrayAttachment(String name, String description, String contentType, InputStream content, String inlineName)
Creates an attachment having the designated name, description, content type (MIME) and content retrieved from the designated string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
getContent()
Gets the content of the attachment represented asInputStream
.-
Methods inherited from class de.aristaflow.adept2.model.mail.SerialisableAttachment
close, getContentType, getDescription, getInlineName, getName
-
-
-
-
Constructor Detail
-
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 asbyte[]
.
-
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 asbyte[]
.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 asbyte[]
.inlineName
- The name used in the corresponding HTML message to refer to this attachment to be inlined. Usenull
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 asbyte[]
.
-
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 asbyte[]
.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 asbyte[]
.inlineName
- The name used in the corresponding HTML message to refer to this attachment to be inlined. Usenull
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 asInputStream
. 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. Usenull
to not inline the attachment.- Throws:
IOException
- If there is a problem reading the content from the designated stream, anIOException
will be thrown.
-
-
Method Detail
-
getContent
public InputStream getContent()
Description copied from class:SerialisableAttachment
Gets the content of the attachment represented asInputStream
.
Note that this should only be called by the receiving service since theInputStream
cannot be serialised.- Specified by:
getContent
in classSerialisableAttachment
- Returns:
- The actual data of the attachment. The caller is responsible for closing.
-
-