java.lang.Object
i2p.susi.webmail.Mail
i2p.susi.webmail.Draft
Represents a draft email message with attachments and Bcc support. Differences from Mail: - Never multipart, body is always text/plain UTF-8 - Attachments are just headers containing name, type, encoding, and path to file - Bcc is a header
Field Summary
Modifier and TypeFieldDescriptionprivate final List<Attachment> Files attached to the draft.private String[]Blind copies, addresses only, enclosed by angle brackets.private static final StringHeader marking an attachment in a sent message.static final StringHeader line carrying the blind-copy recipients of a draft, which a draft otherwise has no way to express in the body.private longSize of the draft's contents, in bytes.Fields inherited from class Mail
cc, contentType, date, dateOnly, dateString, error, formattedDate, HEADER_MATCH, localFormattedDate, markForDeletion, messageID, quotedDate, reply, sender, shortSender, shortSubject, subject, to, uidlModifier and TypeFieldDescription(package private) String[]Addresses only, enclosed by<>.Content-Type header value.The parsed message date.Long date-only format for mail list tooltips.Raw date string from the Date header.Error message from parsing, or empty.Formatted date string in UTC.(package private) static final byte[]Also used byMailPartSee MailPart for why we don't do \r\n\r\n.Formatted date string in local time zone.booleanWhether this message is flagged for deletion.Message-ID as received, not HTML escaped.Quoted date in local time zone, longer format.Address only, enclosed by<>.As received, trimmed only, not HTML escaped.Sender name or address truncated with …Subject truncated with ….As received, trimmed only, not HTML escaped.(package private) String[]May be null.final StringUnique ID assigned by the POP3 server.Constructor Summary
Method Summary
All MethodsModifier and TypeMethodDescriptionintAdds an attachment if not already present.voidRemoves all attachments and deletes their data files.Encodes all attachments as header lines for storage.The live attachment list, so callers can add or drop entries directly.String[]getBcc()The blind-copy recipients found in the draft's Bcc header, with no header meaning none were entered.longgetSize()Includes size of attachments.booleanIs any file attached to this draft?voidremoveAttachment(int index) Removes an attachment by index and deletes its data file.voidOverridden to process attachment and Bcc headers.voidsetSize(long size) Does nothing: a draft computes its own size from the body and its attachments, so there is no server-reported size to record.Methods inherited from class Mail
appendRecipients, appendRecipients, deleteTempBodyFile, getAddress, getAttachmentType, getBody, getHeader, getPart, getRecipientsFromList, getRecipientsFromList, hasBody, hasHeader, hasPart, isNew, isSpam, setHeader, setNew, validateAddressModifier and TypeMethodDescriptionstatic voidappendRecipients(PrintWriter out, String[] recipients, String prefix) Adds all items from the array to the builder, separated by commas This is for display of a forwarded email.static voidappendRecipients(StringBuilder buf, ArrayList<String> recipients, String prefix) Adds all items from the list to the builder, separated by tabs.(package private) static voidDelete the backing file of a body buffer if it is a susimail-new-* temp file.static StringgetAddress(String address) Pull the first e-mail address out of a header line.Get the attachment type.getBody()This contains the header also.This may or may not contain the body also.getPart()The parsed message part.static booleangetRecipientsFromList(ArrayList<String> recipients, String[] ccs, boolean ok) A little misnamed.static booleangetRecipientsFromList(ArrayList<String> recipients, String text, boolean ok) A little misnamed.booleanhasBody()Whether the body has been loaded.booleanWhether the header has been fetched for this UIDL.booleanhasPart()Whether the body has been parsed into a MailPart.booleanisNew()Whether this message is new (unread).booleanisSpam()Whether this message is identified as spam.voidRecord the header bytes fetched from the server.voidsetNew(boolean isNew) Mark this message read or unread.static booleanvalidateAddress(String address) Check an address for the shape a mail server will accept.
Field Details
attachments
Files attached to the draft.bcc
Blind copies, addresses only, enclosed by angle brackets.size
private long sizeSize of the draft's contents, in bytes.HDR_ATTACH
Header marking an attachment in a sent message.- See Also:
HDR_BCC
Header line carrying the blind-copy recipients of a draft, which a draft otherwise has no way to express in the body.- See Also:
Constructor Details
Draft
Start an empty draft with no attachments.- Parameters:
uidl- unique ID for this draft
Method Details
setBody
getSize
setSize
hasAttachment
public boolean hasAttachment()Is any file attached to this draft?- Overrides:
hasAttachmentin classMail- Returns:
- whether attachment is present
getBcc
The blind-copy recipients found in the draft's Bcc header, with no header meaning none were entered.- Returns:
- may be null
getAttachments
The live attachment list, so callers can add or drop entries directly.- Returns:
- non-null, not a copy
addAttachment
Adds an attachment if not already present.- Parameters:
a- the attachment to add- Returns:
- the index of the attachment
removeAttachment
public void removeAttachment(int index) Removes an attachment by index and deletes its data file.- Parameters:
index- the 0-based position in the attachment list; out of range is ignored
clearAttachments
public void clearAttachments()Removes all attachments and deletes their data files.encodeAttachments
Encodes all attachments as header lines for storage.- Returns:
- the encoded attachment headers