1 6 7 package org.contineo.communication; 8 9 import java.util.ArrayList ; 10 import java.util.Collection ; 11 import java.util.Iterator ; 12 import javax.mail.internet.InternetAddress ; 13 17 public class EMail extends Message { 18 19 22 private String authorAddress; 23 26 private String userName; 27 30 private String folder; 31 32 36 private Collection <Recipient> recipients; 37 38 42 private Collection <Attachment> attachments; 43 44 45 46 public EMail() { 47 authorAddress = ""; 48 folder = ""; 49 recipients = new ArrayList <Recipient>(); 50 attachments = new ArrayList <Attachment>(); 51 } 52 53 57 public String getAuthorAddress() { 58 return authorAddress; 59 } 60 61 65 public String getUserName() { 66 return userName; 67 } 68 69 73 public Collection getRecipients() { 74 return recipients; 75 } 76 77 81 public void setAuthorAddress(String address) { 82 authorAddress = address; 83 } 84 85 89 public void setUserName(String uname) { 90 userName = uname; 91 } 92 93 94 public void addRecipient(Recipient rec) { 95 recipients.add(rec); 96 } 97 98 103 public String getFolder() { 104 return folder; 105 } 106 107 112 public void setFolder(String string) { 113 folder = string; 114 } 115 116 121 public Collection getAttachments() { 122 return attachments; 123 } 124 125 public void addAttachment(Attachment attachment) { 126 attachments.add(attachment); 127 } 128 129 public InternetAddress [] getAddresses() throws Exception { 130 InternetAddress [] recs = new InternetAddress [recipients.size()]; 131 Iterator iter = recipients.iterator(); 132 int i = 0; 133 while (iter.hasNext()) { 134 Recipient rec = (Recipient)iter.next(); 135 recs[i] = new InternetAddress (rec.getAddress()); 136 i++; 137 } 138 return recs; 139 } 140 141 public int getAttachmentCount() { 142 return attachments.size(); 143 } 144 } 145 | Popular Tags |