KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > efs > openreports > objects > MailMessage


1 /*
2  * Copyright (C) 2003 Erik Swenson - eswenson@opensourcesoft.net
3  *
4  * This program is free software; you can redistribute it and/or modify it under the terms of the
5  * GNU General Public License as published by the Free Software Foundation; either version 2 of the
6  * License, or (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
10  * the GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License along with this program; if
13  * not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
14  * 02111-1307, USA.
15  *
16  */

17
18 package org.efs.openreports.objects;
19
20 import java.io.Serializable JavaDoc;
21 import java.util.StringTokenizer JavaDoc;
22 import java.util.Vector JavaDoc;
23
24 import org.efs.openreports.util.ByteArrayDataSource;
25
26 public class MailMessage implements Serializable JavaDoc
27 {
28     private static final long serialVersionUID = -5816798771288286268L;
29
30     private String JavaDoc sender;
31     private String JavaDoc subject;
32     private String JavaDoc text;
33
34     private Vector JavaDoc recipients = new Vector JavaDoc();
35     private Vector JavaDoc attachments = new Vector JavaDoc();
36     private Vector JavaDoc htmlImageDataSources = new Vector JavaDoc();
37
38     private ByteArrayDataSource byteArrayDataSource;
39
40     public MailMessage()
41     {
42     }
43
44     public String JavaDoc getSender()
45     {
46         return sender;
47     }
48
49     public void setSender(String JavaDoc sender)
50     {
51         this.sender = sender;
52     }
53
54     public Vector JavaDoc getRecipients()
55     {
56         return recipients;
57     }
58
59     public void setRecipients(Vector JavaDoc recipients)
60     {
61         this.recipients = recipients;
62     }
63
64     public String JavaDoc getSubject()
65     {
66         return subject;
67     }
68
69     public void setSubject(String JavaDoc subject)
70     {
71         this.subject = subject;
72     }
73
74     public String JavaDoc getText()
75     {
76         return text;
77     }
78
79     public void setText(String JavaDoc text)
80     {
81         this.text = text;
82     }
83
84     public ByteArrayDataSource getByteArrayDataSource()
85     {
86         return byteArrayDataSource;
87     }
88
89     public void setByteArrayDataSource(ByteArrayDataSource byteArrayDataSource)
90     {
91         this.byteArrayDataSource = byteArrayDataSource;
92     }
93
94     public Vector JavaDoc getAttachments()
95     {
96         return attachments;
97     }
98
99     public void addAttachment(String JavaDoc fileName)
100     {
101         attachments.add(fileName);
102     }
103
104     public void addRecepient(String JavaDoc recipient)
105     {
106         recipients.add(recipient);
107     }
108
109     public String JavaDoc formatRecipients(String JavaDoc delimiter)
110     {
111         String JavaDoc addresses = "";
112
113         for (int i = 0; i < recipients.size(); i++)
114         {
115             addresses += recipients.get(i) + delimiter;
116         }
117
118         return addresses.substring(0, addresses.length() - 1);
119     }
120
121     public void parseRecipients(String JavaDoc value)
122     {
123         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(value, "\t\n\r\f;,|");
124
125         recipients = new Vector JavaDoc();
126
127         while (st.hasMoreElements())
128         {
129             recipients.add(st.nextElement());
130         }
131     }
132
133     public Vector JavaDoc getHtmlImageDataSources()
134     {
135         return htmlImageDataSources;
136     }
137
138     public void addHtmlImageDataSources(Vector JavaDoc htmlImageDataSources)
139     {
140         this.htmlImageDataSources.addAll(htmlImageDataSources);
141     }
142
143 }
Popular Tags