jodd.mail
Class EmailAttachment

java.lang.Object
  extended by jodd.mail.EmailAttachment
Direct Known Subclasses:
ByteArrayAttachment, DataSourceAttachment, FileAttachment, InputStreamAttachment

public abstract class EmailAttachment
extends java.lang.Object

Email attachment.


Field Summary
protected  java.lang.String contentId
           
protected  java.lang.String name
           
protected  int size
           
protected  EmailMessage targetMessage
           
 
Constructor Summary
protected EmailAttachment(java.lang.String name, java.lang.String contentId)
          Creates new attachment with given name and content id for inline attachments.
 
Method Summary
static EmailAttachmentBuilder attachment()
          Creates builder for convenient building of the email attachments.
 java.lang.String getContentId()
          Returns content id for inline attachments.
abstract  javax.activation.DataSource getDataSource()
          Returns DataSource implementation, depending of attachment source.
 java.lang.String getName()
          Returns attachment name.
 int getSize()
          Returns size of received attachment,
 boolean isEmbeddedInto(EmailMessage emailMessage)
          Returns true if attachment is embedded into provided message.
 boolean isInline()
          Returns true if it is inline attachment.
 void setEmbeddedMessage(EmailMessage emailMessage)
          Sets target message for embedded attachments.
protected  void setSize(int size)
           
 byte[] toByteArray()
          Returns byte content of the attachment.
 void writeToFile(java.io.File destination)
          Saves attachment to a file.
 void writeToStream(java.io.OutputStream out)
          Saves attachment to output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected final java.lang.String name

contentId

protected final java.lang.String contentId

targetMessage

protected EmailMessage targetMessage

size

protected int size
Constructor Detail

EmailAttachment

protected EmailAttachment(java.lang.String name,
                          java.lang.String contentId)
Creates new attachment with given name and content id for inline attachments. Content id may be null if attachment is not embedded.

Method Detail

attachment

public static EmailAttachmentBuilder attachment()
Creates builder for convenient building of the email attachments.


getName

public java.lang.String getName()
Returns attachment name.


getContentId

public java.lang.String getContentId()
Returns content id for inline attachments. Equals to null when attachment is not embedded.


isInline

public boolean isInline()
Returns true if it is inline attachment.


setEmbeddedMessage

public void setEmbeddedMessage(EmailMessage emailMessage)
Sets target message for embedded attachments.


isEmbeddedInto

public boolean isEmbeddedInto(EmailMessage emailMessage)
Returns true if attachment is embedded into provided message.


getDataSource

public abstract javax.activation.DataSource getDataSource()
Returns DataSource implementation, depending of attachment source.


getSize

public int getSize()
Returns size of received attachment,


setSize

protected void setSize(int size)

toByteArray

public byte[] toByteArray()
Returns byte content of the attachment.


writeToFile

public void writeToFile(java.io.File destination)
Saves attachment to a file.


writeToStream

public void writeToStream(java.io.OutputStream out)
Saves attachment to output stream.



Copyright © 2003-2013 Jodd Team