001: package org.contineo.core.communication;
002:
003: import java.util.HashMap;
004: import java.util.HashSet;
005: import java.util.Iterator;
006: import java.util.Map;
007: import java.util.Set;
008:
009: import javax.mail.internet.InternetAddress;
010:
011: /**
012: * @author Michael Scholz, Marco Meschieri
013: */
014: public class EMail extends Message {
015:
016: private String authorAddress = "";
017:
018: private String userName = "";
019:
020: private String folder = "";
021:
022: // Refers to the original email id
023: private String emailId = "";
024:
025: // The e-mail account used to fetch this message
026: private int accountId;
027:
028: private Set<Recipient> recipients = new HashSet<Recipient>();
029:
030: private Map<Integer, Attachment> attachments = new HashMap<Integer, Attachment>();
031:
032: public EMail() {
033: }
034:
035: public String getEmailId() {
036: return emailId;
037: }
038:
039: public void setEmailId(String emailId) {
040: this .emailId = emailId;
041: }
042:
043: public int getAccountId() {
044: return accountId;
045: }
046:
047: public void setAccountId(int accountId) {
048: this .accountId = accountId;
049: }
050:
051: public String getAuthorAddress() {
052: return authorAddress;
053: }
054:
055: public String getUserName() {
056: return userName;
057: }
058:
059: public Set<Recipient> getRecipients() {
060: return recipients;
061: }
062:
063: public void setAuthorAddress(String address) {
064: authorAddress = address;
065: }
066:
067: public void setUserName(String uname) {
068: userName = uname;
069: }
070:
071: public void addRecipient(Recipient rec) {
072: recipients.add(rec);
073: }
074:
075: public String getFolder() {
076: return folder;
077: }
078:
079: public void setFolder(String string) {
080: folder = string;
081: }
082:
083: public Map<Integer, Attachment> getAttachments() {
084: return attachments;
085: }
086:
087: public Attachment getAttachment(int partId) {
088: return attachments.get(partId);
089: }
090:
091: public void addAttachment(int partId, Attachment attachment) {
092: attachments.put(partId, attachment);
093: }
094:
095: public InternetAddress[] getAddresses() throws Exception {
096: InternetAddress[] recs = new InternetAddress[recipients.size()];
097: Iterator iter = recipients.iterator();
098: int i = 0;
099:
100: while (iter.hasNext()) {
101: Recipient rec = (Recipient) iter.next();
102: recs[i] = new InternetAddress(rec.getAddress());
103: i++;
104: }
105:
106: return recs;
107: }
108:
109: public int getAttachmentCount() {
110: return attachments.size();
111: }
112:
113: public void setRecipients(Set<Recipient> recipients) {
114: this .recipients = recipients;
115: }
116:
117: public void setAttachments(Map<Integer, Attachment> attachments) {
118: this.attachments = attachments;
119: }
120: }
|