Package de.aristaflow.adept2.model.mail
Class DataSourceAttachment
- java.lang.Object
-
- de.aristaflow.adept2.model.mail.SerialisableAttachment
-
- de.aristaflow.adept2.model.mail.DataSourceAttachment
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
public class DataSourceAttachment extends SerialisableAttachment
ASerialisableAttachment
having a datasource as content. If this attachment is serialised, it will become aByteArrayDataSource
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.activation.DataSource
dataSource
The data source providing the content.-
Fields inherited from class de.aristaflow.adept2.model.mail.SerialisableAttachment
contentType, description, inlineName, name
-
-
Constructor Summary
Constructors Constructor Description DataSourceAttachment(String name, String description, String contentType, javax.activation.DataSource dataSource)
Creates an attachment having the designated name, description and content type retrieving the content from the designated data source.DataSourceAttachment(String name, String description, String contentType, javax.activation.DataSource dataSource, boolean inline)
Creates an attachment having the designated name, description and content type retrieving the content from the designated data source.DataSourceAttachment(String name, String description, String contentType, javax.activation.DataSource dataSource, String inlineName)
Creates an attachment having the designated name, description and content type retrieving the content from the designated data source.DataSourceAttachment(String name, String description, javax.activation.DataSource dataSource)
Creates an attachment having the designated name and description retrieving the content from the designated data source.DataSourceAttachment(javax.activation.DataSource dataSource, String description)
Creates an attachment having the designated data source (content, name and content type).DataSourceAttachment(javax.activation.DataSource dataSource, String description, boolean inline)
Creates an attachment having the designated data source (content, name and content type).DataSourceAttachment(javax.activation.DataSource dataSource, String description, String inlineName)
Creates an attachment having the designated data source (content, name and content type).
-
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
-
DataSourceAttachment
public DataSourceAttachment(String name, String description, javax.activation.DataSource dataSource)
Creates an attachment having the designated name and description retrieving the content from the designated data source. The content type is set to "application/octet-stream". This allows to override name and content type of the data source.- Parameters:
name
- The name of the attachment.description
- The description of the attachment.dataSource
- The data source providing the content (only).
-
DataSourceAttachment
public DataSourceAttachment(javax.activation.DataSource dataSource, String description)
Creates an attachment having the designated data source (content, name and content type).- Parameters:
dataSource
- The data source providing the content (and the name and the content type).description
- The description of the attachment.
-
DataSourceAttachment
public DataSourceAttachment(String name, String description, String contentType, javax.activation.DataSource dataSource)
Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. This allows to override name and content type of the data source.- Parameters:
name
- The name of the attachment.description
- The description of the attachment.contentType
- The content type (MIME) of the attachment.dataSource
- The data source providing the content (only).
-
DataSourceAttachment
public DataSourceAttachment(javax.activation.DataSource dataSource, String description, boolean inline)
Creates an attachment having the designated data source (content, name and content type).- Parameters:
dataSource
- The data source providing the content (and the name and the content type).description
- The description of the attachment.inline
- Whether to inline this attachment in case of an HTML message using the designated name.
-
DataSourceAttachment
public DataSourceAttachment(String name, String description, String contentType, javax.activation.DataSource dataSource, boolean inline)
Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. This allows to override name and content type of the data source.- Parameters:
name
- The name of the attachment.description
- The description of the attachment.contentType
- The content type (MIME) of the attachment.dataSource
- The data source providing the content (only).inline
- Whether to inline this attachment in case of an HTML message using the designated name.
-
DataSourceAttachment
public DataSourceAttachment(javax.activation.DataSource dataSource, String description, String inlineName)
Creates an attachment having the designated data source (content, name and content type).- Parameters:
dataSource
- The data source providing the content (and the name and the content type).description
- The description of the attachment.inlineName
- The name used in the corresponding HTML message to refer to this attachment to be inlined. Usenull
to not inline the attachment.
-
DataSourceAttachment
public DataSourceAttachment(String name, String description, String contentType, javax.activation.DataSource dataSource, String inlineName)
Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. This allows to override name and content type of the data source.- Parameters:
name
- The name of the attachment.description
- The description of the attachment.contentType
- The content type (MIME) of the attachment.dataSource
- The data source providing the content (only).inlineName
- The name used in the corresponding HTML message to refer to this attachment to be inlined. Usenull
to not inline the attachment.
-
-
Method Detail
-
getContent
public InputStream getContent() throws IOException
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.
- Throws:
IOException
- If there are problems retrieving the content, for instance converting the transferred serialisable data to anInputStream
, anIOException
will be thrown.
-
-