KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > echo2example > email > faux > FauxMessage


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package echo2example.email.faux;
31
32 import java.io.IOException JavaDoc;
33 import java.io.InputStream JavaDoc;
34 import java.io.OutputStream JavaDoc;
35 import java.util.Date JavaDoc;
36 import java.util.Enumeration JavaDoc;
37
38 import javax.activation.DataHandler JavaDoc;
39 import javax.mail.Address JavaDoc;
40 import javax.mail.Flags JavaDoc;
41 import javax.mail.Message JavaDoc;
42 import javax.mail.MessagingException JavaDoc;
43 import javax.mail.Multipart JavaDoc;
44
45 /**
46  * The faux <code>Message</code> implementation.
47  * This class provides only the minimal implementation of the
48  * <code>Message</code> base class necessary for operation of
49  * the web mail example.
50  */

51 public class FauxMessage extends Message JavaDoc {
52     
53     private Address JavaDoc[] from;
54     private String JavaDoc subject;
55     private String JavaDoc content;
56     private Date JavaDoc receivedDate;
57     private Address JavaDoc[] to, cc, bcc;
58     
59     /**
60      * Creates a new <code>FauxMessage</code>
61      *
62      * @param from the sender
63      * @param receivedDate the date the message was received
64      * @param to an array of "to" recipients
65      * @param cc an array of "cc" recipients
66      * @param bcc an array of "bcc" recipients
67      * @param subject the subject of the message
68      * @param content the content of the message
69      */

70     public FauxMessage(Address JavaDoc from, Date JavaDoc receivedDate,
71             Address JavaDoc[] to, Address JavaDoc[] cc, Address JavaDoc[] bcc,
72             String JavaDoc subject, String JavaDoc content) {
73         this.receivedDate = receivedDate;
74         this.from = new Address JavaDoc[]{from};
75         this.to = to;
76         this.cc = cc;
77         this.bcc = bcc;
78         this.subject = subject;
79         this.content = content;
80     }
81
82     /**
83      * @see javax.mail.Message#addFrom(javax.mail.Address[])
84      */

85     public void addFrom(Address JavaDoc[] from) throws MessagingException JavaDoc {
86         throw new UnsupportedOperationException JavaDoc();
87     }
88
89     /**
90      * @see javax.mail.Part#addHeader(java.lang.String, java.lang.String)
91      */

92     public void addHeader(String JavaDoc arg0, String JavaDoc arg1) throws MessagingException JavaDoc {
93         throw new UnsupportedOperationException JavaDoc();
94     }
95
96     /**
97      * @see javax.mail.Message#addRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])
98      */

99     public void addRecipients(RecipientType arg0, Address JavaDoc[] arg1) throws MessagingException JavaDoc {
100         throw new UnsupportedOperationException JavaDoc();
101     }
102
103     /**
104      * @see javax.mail.Part#getAllHeaders()
105      */

106     public Enumeration JavaDoc getAllHeaders() throws MessagingException JavaDoc {
107         throw new UnsupportedOperationException JavaDoc();
108     }
109
110     /**
111      * @see javax.mail.Part#getContent()
112      */

113     public Object JavaDoc getContent() throws IOException JavaDoc, MessagingException JavaDoc {
114         return content;
115     }
116
117     /**
118      * @see javax.mail.Part#getContentType()
119      */

120     public String JavaDoc getContentType() throws MessagingException JavaDoc {
121         return "text/plain";
122     }
123
124     /**
125      * @see javax.mail.Part#getDataHandler()
126      */

127     public DataHandler JavaDoc getDataHandler() throws MessagingException JavaDoc {
128         throw new UnsupportedOperationException JavaDoc();
129     }
130
131     /**
132      * @see javax.mail.Part#getDescription()
133      */

134     public String JavaDoc getDescription() throws MessagingException JavaDoc {
135         throw new UnsupportedOperationException JavaDoc();
136     }
137
138     /**
139      * @see javax.mail.Part#getDisposition()
140      */

141     public String JavaDoc getDisposition() throws MessagingException JavaDoc {
142         throw new UnsupportedOperationException JavaDoc();
143     }
144
145     /**
146      * @see javax.mail.Part#getFileName()
147      */

148     public String JavaDoc getFileName() throws MessagingException JavaDoc {
149         throw new UnsupportedOperationException JavaDoc();
150     }
151
152     /**
153      * @see javax.mail.Message#getFlags()
154      */

155     public Flags JavaDoc getFlags() throws MessagingException JavaDoc {
156         throw new UnsupportedOperationException JavaDoc();
157     }
158
159     /**
160      * @see javax.mail.Message#getFrom()
161      */

162     public Address JavaDoc[] getFrom() throws MessagingException JavaDoc {
163         return from;
164     }
165
166     /**
167      * @see javax.mail.Part#getHeader(java.lang.String)
168      */

169     public String JavaDoc[] getHeader(String JavaDoc arg0) throws MessagingException JavaDoc {
170         throw new UnsupportedOperationException JavaDoc();
171     }
172
173     /**
174      * @see javax.mail.Part#getInputStream()
175      */

176     public InputStream JavaDoc getInputStream() throws IOException JavaDoc, MessagingException JavaDoc {
177         throw new UnsupportedOperationException JavaDoc();
178     }
179
180     /**
181      * @see javax.mail.Part#getLineCount()
182      */

183     public int getLineCount() throws MessagingException JavaDoc {
184         throw new UnsupportedOperationException JavaDoc();
185     }
186
187     /**
188      * @see javax.mail.Part#getMatchingHeaders(java.lang.String[])
189      */

190     public Enumeration JavaDoc getMatchingHeaders(String JavaDoc[] arg0) throws MessagingException JavaDoc {
191         throw new UnsupportedOperationException JavaDoc();
192     }
193
194     /**
195      * @see javax.mail.Part#getNonMatchingHeaders(java.lang.String[])
196      */

197     public Enumeration JavaDoc getNonMatchingHeaders(String JavaDoc[] arg0) throws MessagingException JavaDoc {
198         throw new UnsupportedOperationException JavaDoc();
199     }
200
201     /**
202      * @see javax.mail.Message#getReceivedDate()
203      */

204     public Date JavaDoc getReceivedDate() throws MessagingException JavaDoc {
205         return receivedDate;
206     }
207
208     /**
209      * @see javax.mail.Message#getRecipients(javax.mail.Message.RecipientType)
210      */

211     public Address JavaDoc[] getRecipients(RecipientType recipientType) throws MessagingException JavaDoc {
212         if (recipientType.equals(RecipientType.TO)) {
213             return to;
214         } else if (recipientType.equals(RecipientType.CC)) {
215             return cc;
216         } else if (recipientType.equals(RecipientType.BCC)) {
217             return bcc;
218         } else {
219             throw new IllegalArgumentException JavaDoc();
220         }
221     }
222
223     /**
224      * @see javax.mail.Message#getSentDate()
225      */

226     public Date JavaDoc getSentDate() throws MessagingException JavaDoc {
227         return receivedDate;
228     }
229
230     /**
231      * @see javax.mail.Part#getSize()
232      */

233     public int getSize() throws MessagingException JavaDoc {
234         throw new UnsupportedOperationException JavaDoc();
235     }
236
237     /**
238      * @see javax.mail.Message#getSubject()
239      */

240     public String JavaDoc getSubject() throws MessagingException JavaDoc {
241         return subject;
242     }
243
244     /**
245      * @see javax.mail.Part#isMimeType(java.lang.String)
246      */

247     public boolean isMimeType(String JavaDoc arg0) throws MessagingException JavaDoc {
248         throw new UnsupportedOperationException JavaDoc();
249     }
250
251     /**
252      * @see javax.mail.Part#removeHeader(java.lang.String)
253      */

254     public void removeHeader(String JavaDoc arg0) throws MessagingException JavaDoc {
255         throw new UnsupportedOperationException JavaDoc();
256     }
257
258     /**
259      * @see javax.mail.Message#reply(boolean)
260      */

261     public Message JavaDoc reply(boolean arg0) throws MessagingException JavaDoc {
262         throw new UnsupportedOperationException JavaDoc();
263     }
264
265     /**
266      * @see javax.mail.Message#saveChanges()
267      */

268     public void saveChanges() throws MessagingException JavaDoc {
269         throw new UnsupportedOperationException JavaDoc();
270     }
271
272     /**
273      * @see javax.mail.Part#setContent(javax.mail.Multipart)
274      */

275     public void setContent(Multipart JavaDoc arg0) throws MessagingException JavaDoc {
276         throw new UnsupportedOperationException JavaDoc();
277     }
278
279     /**
280      * @see javax.mail.Part#setContent(java.lang.Object, java.lang.String)
281      */

282     public void setContent(Object JavaDoc arg0, String JavaDoc arg1) throws MessagingException JavaDoc {
283         throw new UnsupportedOperationException JavaDoc();
284     }
285
286     /**
287      * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
288      */

289     public void setDataHandler(DataHandler JavaDoc arg0) throws MessagingException JavaDoc {
290         throw new UnsupportedOperationException JavaDoc();
291     }
292
293     /**
294      * @see javax.mail.Part#setDescription(java.lang.String)
295      */

296     public void setDescription(String JavaDoc arg0) throws MessagingException JavaDoc {
297         throw new UnsupportedOperationException JavaDoc();
298     }
299
300     /**
301      * @see javax.mail.Part#setDisposition(java.lang.String)
302      */

303     public void setDisposition(String JavaDoc arg0) throws MessagingException JavaDoc {
304         throw new UnsupportedOperationException JavaDoc();
305     }
306
307     /**
308      * @see javax.mail.Part#setFileName(java.lang.String)
309      */

310     public void setFileName(String JavaDoc arg0) throws MessagingException JavaDoc {
311         throw new UnsupportedOperationException JavaDoc();
312     }
313
314     /**
315      * @see javax.mail.Message#setFlags(javax.mail.Flags, boolean)
316      */

317     public void setFlags(Flags JavaDoc arg0, boolean arg1) throws MessagingException JavaDoc {
318         throw new UnsupportedOperationException JavaDoc();
319     }
320
321     /**
322      * @see javax.mail.Message#setFrom()
323      */

324     public void setFrom() throws MessagingException JavaDoc {
325         throw new UnsupportedOperationException JavaDoc();
326     }
327
328     /**
329      * @see javax.mail.Message#setFrom(javax.mail.Address)
330      */

331     public void setFrom(Address JavaDoc arg0) throws MessagingException JavaDoc {
332         throw new UnsupportedOperationException JavaDoc();
333     }
334
335     /**
336      * @see javax.mail.Part#setHeader(java.lang.String, java.lang.String)
337      */

338     public void setHeader(String JavaDoc arg0, String JavaDoc arg1) throws MessagingException JavaDoc {
339         throw new UnsupportedOperationException JavaDoc();
340     }
341
342     /**
343      * @see javax.mail.Message#setRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])
344      */

345     public void setRecipients(RecipientType arg0, Address JavaDoc[] arg1) throws MessagingException JavaDoc {
346         throw new UnsupportedOperationException JavaDoc();
347     }
348
349     /**
350      * @see javax.mail.Message#setSentDate(java.util.Date)
351      */

352     public void setSentDate(Date JavaDoc arg0) throws MessagingException JavaDoc {
353         throw new UnsupportedOperationException JavaDoc();
354     }
355
356     /**
357      * @see javax.mail.Message#setSubject(java.lang.String)
358      */

359     public void setSubject(String JavaDoc arg0) throws MessagingException JavaDoc {
360         throw new UnsupportedOperationException JavaDoc();
361     }
362
363     /**
364      * @see javax.mail.Part#setText(java.lang.String)
365      */

366     public void setText(String JavaDoc arg0) throws MessagingException JavaDoc {
367         throw new UnsupportedOperationException JavaDoc();
368     }
369
370     /**
371      * @see javax.mail.Part#writeTo(java.io.OutputStream)
372      */

373     public void writeTo(OutputStream JavaDoc arg0) throws IOException JavaDoc, MessagingException JavaDoc {
374         throw new UnsupportedOperationException JavaDoc();
375     }
376 }
Popular Tags