public class EmailAttachment<T extends javax.activation.DataSource>
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
EmailAttachment(java.lang.String name,
java.lang.String contentId,
boolean isInline,
T dataSource)
Creates new attachment with given name and content id for inline attachments.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getContentId()
Returns content id for inline attachments.
|
java.lang.String |
getContentType()
Returns content type of
DataSource . |
T |
getDataSource()
Returns
DataSource implementation, depending on attachment source. |
java.lang.String |
getEncodedName()
Returns encoded attachment name.
|
java.lang.String |
getName()
Returns attachment name.
|
int |
getSize()
Returns size of attachment.
|
boolean |
isEmbedded()
Returns
true if the attachment is embedded. |
boolean |
isEmbeddedInto(EmailMessage emailMessage)
Returns
true if attachment is embedded into provided message. |
boolean |
isInline()
Returns
true if it is an inline attachment. |
protected EmailAttachment<T> |
setContentId(java.lang.String contentId)
Sets content ID.
|
EmailAttachment<T> |
setEmbeddedMessage(EmailMessage emailMessage)
Sets target message for embedded attachments.
|
protected EmailAttachment<T> |
setInline(boolean isInline)
Sets whether attachment is inline.
|
protected EmailAttachment<T> |
setSize(int size)
Sets size of attachment.
|
byte[] |
toByteArray()
Returns byte content of the attachment.
|
static EmailAttachmentBuilder |
with()
Returns new/empty
EmailAttachmentBuilder . |
void |
writeToFile(java.io.File destination)
Saves attachment to a file.
|
void |
writeToStream(java.io.OutputStream out)
Saves attachment to the output stream.
|
protected EmailAttachment(java.lang.String name, java.lang.String contentId, boolean isInline, T dataSource)
contentId
- Value may be null
if attachment is not embedded.isInline
- true
if the attachment is inline.name
- Email name may be null
as well.MimeUtility.decodeText(String)
public static EmailAttachmentBuilder with()
EmailAttachmentBuilder
.EmailAttachmentBuilder
.public java.lang.String getName()
null
.public java.lang.String getEncodedName()
null
.public java.lang.String getContentId()
Value is null
when attachment is not embedded.
isEmbedded()
public boolean isEmbedded()
true
if the attachment is embedded.
Embedded attachment is one when getContentId()
is not null
.
true
if the attachment is embedded.public boolean isInline()
true
if it is an inline attachment.true
if it is an inline attachment.protected EmailAttachment<T> setInline(boolean isInline)
isInline
- true
for inline.protected EmailAttachment<T> setContentId(java.lang.String contentId)
contentId
- content ID of EmailAttachment
.public EmailAttachment<T> setEmbeddedMessage(EmailMessage emailMessage)
emailMessage
- target EmailMessage
.public boolean isEmbeddedInto(EmailMessage emailMessage)
true
if attachment is embedded into provided message.emailMessage
- target EmailMessage
.true
if attachment is embedded into provided message.public T getDataSource()
DataSource
implementation, depending on attachment source.public java.lang.String getContentType()
DataSource
.DataSource
.public int getSize()
DataSource
.protected EmailAttachment<T> setSize(int size)
size
- the size of the attachment.public byte[] toByteArray()
public void writeToFile(java.io.File destination)
destination
- The destination file to be written.public void writeToStream(java.io.OutputStream out)
out
- OutputStream where attachment should be copied to.Copyright © 2003-present Jodd Team