KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > contineo > communication > EMail


1 /*
2  * EMail.java
3  *
4  * Created on 26. Februar 2004, 20:05
5  */

6
7 package org.contineo.communication;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.Collection JavaDoc;
11 import java.util.Iterator JavaDoc;
12 import javax.mail.internet.InternetAddress JavaDoc;
13 /**
14  *
15  * @author Michael Scholz
16  */

17 public class EMail extends Message {
18     
19     /**
20      * @uml.property name="authorAddress"
21      */

22     private String JavaDoc authorAddress;
23     /**
24      * @uml.property name="userName"
25      */

26     private String JavaDoc userName;
27     /**
28      * @uml.property name="folder"
29      */

30     private String JavaDoc folder;
31
32     /**
33      * @uml.property name="recipients"
34      * @uml.associationEnd
35      */

36     private Collection JavaDoc<Recipient> recipients;
37
38     /**
39      * @uml.property name="attachments"
40      * @uml.associationEnd
41      */

42     private Collection JavaDoc<Attachment> attachments;
43
44     
45     /** Creates a new instance of EMail */
46     public EMail() {
47         authorAddress = "";
48         folder = "";
49         recipients = new ArrayList JavaDoc<Recipient>();
50         attachments = new ArrayList JavaDoc<Attachment>();
51     }
52
53     /**
54      *
55      * @uml.property name="authorAddress"
56      */

57     public String JavaDoc getAuthorAddress() {
58         return authorAddress;
59     }
60
61     /**
62      *
63      * @uml.property name="userName"
64      */

65     public String JavaDoc getUserName() {
66         return userName;
67     }
68
69     /**
70      *
71      * @uml.property name="recipients"
72      */

73     public Collection JavaDoc getRecipients() {
74         return recipients;
75     }
76
77     /**
78      *
79      * @uml.property name="authorAddress"
80      */

81     public void setAuthorAddress(String JavaDoc address) {
82         authorAddress = address;
83     }
84
85     /**
86      *
87      * @uml.property name="userName"
88      */

89     public void setUserName(String JavaDoc uname) {
90         userName = uname;
91     }
92
93     
94     public void addRecipient(Recipient rec) {
95         recipients.add(rec);
96     }
97
98     /**
99      * @return
100      *
101      * @uml.property name="folder"
102      */

103     public String JavaDoc getFolder() {
104         return folder;
105     }
106
107     /**
108      * @param string
109      *
110      * @uml.property name="folder"
111      */

112     public void setFolder(String JavaDoc string) {
113         folder = string;
114     }
115
116     /**
117      * @return
118      *
119      * @uml.property name="attachments"
120      */

121     public Collection JavaDoc getAttachments() {
122         return attachments;
123     }
124
125     public void addAttachment(Attachment attachment) {
126         attachments.add(attachment);
127     }
128     
129     public InternetAddress JavaDoc[] getAddresses() throws Exception JavaDoc {
130         InternetAddress JavaDoc[] recs = new InternetAddress JavaDoc[recipients.size()];
131         Iterator JavaDoc iter = recipients.iterator();
132         int i = 0;
133         while (iter.hasNext()) {
134             Recipient rec = (Recipient)iter.next();
135             recs[i] = new InternetAddress JavaDoc(rec.getAddress());
136             i++;
137         }
138         return recs;
139     }
140     
141     public int getAttachmentCount() {
142         return attachments.size();
143     }
144 }
145
Popular Tags