001: /*
002: * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003: * Copyright (C) 2002-2005 NextApp, Inc.
004: *
005: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006: *
007: * The contents of this file are subject to the Mozilla Public License Version
008: * 1.1 (the "License"); you may not use this file except in compliance with
009: * the License. You may obtain a copy of the License at
010: * http://www.mozilla.org/MPL/
011: *
012: * Software distributed under the License is distributed on an "AS IS" basis,
013: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014: * for the specific language governing rights and limitations under the
015: * License.
016: *
017: * Alternatively, the contents of this file may be used under the terms of
018: * either the GNU General Public License Version 2 or later (the "GPL"), or
019: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020: * in which case the provisions of the GPL or the LGPL are applicable instead
021: * of those above. If you wish to allow use of your version of this file only
022: * under the terms of either the GPL or the LGPL, and not to allow others to
023: * use your version of this file under the terms of the MPL, indicate your
024: * decision by deleting the provisions above and replace them with the notice
025: * and other provisions required by the GPL or the LGPL. If you do not delete
026: * the provisions above, a recipient may use your version of this file under
027: * the terms of any one of the MPL, the GPL or the LGPL.
028: */
029:
030: package echo2example.email.faux;
031:
032: import java.io.IOException;
033: import java.io.InputStream;
034: import java.io.OutputStream;
035: import java.util.Date;
036: import java.util.Enumeration;
037:
038: import javax.activation.DataHandler;
039: import javax.mail.Address;
040: import javax.mail.Flags;
041: import javax.mail.Message;
042: import javax.mail.MessagingException;
043: import javax.mail.Multipart;
044:
045: /**
046: * The faux <code>Message</code> implementation.
047: * This class provides only the minimal implementation of the
048: * <code>Message</code> base class necessary for operation of
049: * the web mail example.
050: */
051: public class FauxMessage extends Message {
052:
053: private Address[] from;
054: private String subject;
055: private String content;
056: private Date receivedDate;
057: private Address[] to, cc, bcc;
058:
059: /**
060: * Creates a new <code>FauxMessage</code>
061: *
062: * @param from the sender
063: * @param receivedDate the date the message was received
064: * @param to an array of "to" recipients
065: * @param cc an array of "cc" recipients
066: * @param bcc an array of "bcc" recipients
067: * @param subject the subject of the message
068: * @param content the content of the message
069: */
070: public FauxMessage(Address from, Date receivedDate, Address[] to,
071: Address[] cc, Address[] bcc, String subject, String content) {
072: this .receivedDate = receivedDate;
073: this .from = new Address[] { from };
074: this .to = to;
075: this .cc = cc;
076: this .bcc = bcc;
077: this .subject = subject;
078: this .content = content;
079: }
080:
081: /**
082: * @see javax.mail.Message#addFrom(javax.mail.Address[])
083: */
084: public void addFrom(Address[] from) throws MessagingException {
085: throw new UnsupportedOperationException();
086: }
087:
088: /**
089: * @see javax.mail.Part#addHeader(java.lang.String, java.lang.String)
090: */
091: public void addHeader(String arg0, String arg1)
092: throws MessagingException {
093: throw new UnsupportedOperationException();
094: }
095:
096: /**
097: * @see javax.mail.Message#addRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])
098: */
099: public void addRecipients(RecipientType arg0, Address[] arg1)
100: throws MessagingException {
101: throw new UnsupportedOperationException();
102: }
103:
104: /**
105: * @see javax.mail.Part#getAllHeaders()
106: */
107: public Enumeration getAllHeaders() throws MessagingException {
108: throw new UnsupportedOperationException();
109: }
110:
111: /**
112: * @see javax.mail.Part#getContent()
113: */
114: public Object getContent() throws IOException, MessagingException {
115: return content;
116: }
117:
118: /**
119: * @see javax.mail.Part#getContentType()
120: */
121: public String getContentType() throws MessagingException {
122: return "text/plain";
123: }
124:
125: /**
126: * @see javax.mail.Part#getDataHandler()
127: */
128: public DataHandler getDataHandler() throws MessagingException {
129: throw new UnsupportedOperationException();
130: }
131:
132: /**
133: * @see javax.mail.Part#getDescription()
134: */
135: public String getDescription() throws MessagingException {
136: throw new UnsupportedOperationException();
137: }
138:
139: /**
140: * @see javax.mail.Part#getDisposition()
141: */
142: public String getDisposition() throws MessagingException {
143: throw new UnsupportedOperationException();
144: }
145:
146: /**
147: * @see javax.mail.Part#getFileName()
148: */
149: public String getFileName() throws MessagingException {
150: throw new UnsupportedOperationException();
151: }
152:
153: /**
154: * @see javax.mail.Message#getFlags()
155: */
156: public Flags getFlags() throws MessagingException {
157: throw new UnsupportedOperationException();
158: }
159:
160: /**
161: * @see javax.mail.Message#getFrom()
162: */
163: public Address[] getFrom() throws MessagingException {
164: return from;
165: }
166:
167: /**
168: * @see javax.mail.Part#getHeader(java.lang.String)
169: */
170: public String[] getHeader(String arg0) throws MessagingException {
171: throw new UnsupportedOperationException();
172: }
173:
174: /**
175: * @see javax.mail.Part#getInputStream()
176: */
177: public InputStream getInputStream() throws IOException,
178: MessagingException {
179: throw new UnsupportedOperationException();
180: }
181:
182: /**
183: * @see javax.mail.Part#getLineCount()
184: */
185: public int getLineCount() throws MessagingException {
186: throw new UnsupportedOperationException();
187: }
188:
189: /**
190: * @see javax.mail.Part#getMatchingHeaders(java.lang.String[])
191: */
192: public Enumeration getMatchingHeaders(String[] arg0)
193: throws MessagingException {
194: throw new UnsupportedOperationException();
195: }
196:
197: /**
198: * @see javax.mail.Part#getNonMatchingHeaders(java.lang.String[])
199: */
200: public Enumeration getNonMatchingHeaders(String[] arg0)
201: throws MessagingException {
202: throw new UnsupportedOperationException();
203: }
204:
205: /**
206: * @see javax.mail.Message#getReceivedDate()
207: */
208: public Date getReceivedDate() throws MessagingException {
209: return receivedDate;
210: }
211:
212: /**
213: * @see javax.mail.Message#getRecipients(javax.mail.Message.RecipientType)
214: */
215: public Address[] getRecipients(RecipientType recipientType)
216: throws MessagingException {
217: if (recipientType.equals(RecipientType.TO)) {
218: return to;
219: } else if (recipientType.equals(RecipientType.CC)) {
220: return cc;
221: } else if (recipientType.equals(RecipientType.BCC)) {
222: return bcc;
223: } else {
224: throw new IllegalArgumentException();
225: }
226: }
227:
228: /**
229: * @see javax.mail.Message#getSentDate()
230: */
231: public Date getSentDate() throws MessagingException {
232: return receivedDate;
233: }
234:
235: /**
236: * @see javax.mail.Part#getSize()
237: */
238: public int getSize() throws MessagingException {
239: throw new UnsupportedOperationException();
240: }
241:
242: /**
243: * @see javax.mail.Message#getSubject()
244: */
245: public String getSubject() throws MessagingException {
246: return subject;
247: }
248:
249: /**
250: * @see javax.mail.Part#isMimeType(java.lang.String)
251: */
252: public boolean isMimeType(String arg0) throws MessagingException {
253: throw new UnsupportedOperationException();
254: }
255:
256: /**
257: * @see javax.mail.Part#removeHeader(java.lang.String)
258: */
259: public void removeHeader(String arg0) throws MessagingException {
260: throw new UnsupportedOperationException();
261: }
262:
263: /**
264: * @see javax.mail.Message#reply(boolean)
265: */
266: public Message reply(boolean arg0) throws MessagingException {
267: throw new UnsupportedOperationException();
268: }
269:
270: /**
271: * @see javax.mail.Message#saveChanges()
272: */
273: public void saveChanges() throws MessagingException {
274: throw new UnsupportedOperationException();
275: }
276:
277: /**
278: * @see javax.mail.Part#setContent(javax.mail.Multipart)
279: */
280: public void setContent(Multipart arg0) throws MessagingException {
281: throw new UnsupportedOperationException();
282: }
283:
284: /**
285: * @see javax.mail.Part#setContent(java.lang.Object, java.lang.String)
286: */
287: public void setContent(Object arg0, String arg1)
288: throws MessagingException {
289: throw new UnsupportedOperationException();
290: }
291:
292: /**
293: * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
294: */
295: public void setDataHandler(DataHandler arg0)
296: throws MessagingException {
297: throw new UnsupportedOperationException();
298: }
299:
300: /**
301: * @see javax.mail.Part#setDescription(java.lang.String)
302: */
303: public void setDescription(String arg0) throws MessagingException {
304: throw new UnsupportedOperationException();
305: }
306:
307: /**
308: * @see javax.mail.Part#setDisposition(java.lang.String)
309: */
310: public void setDisposition(String arg0) throws MessagingException {
311: throw new UnsupportedOperationException();
312: }
313:
314: /**
315: * @see javax.mail.Part#setFileName(java.lang.String)
316: */
317: public void setFileName(String arg0) throws MessagingException {
318: throw new UnsupportedOperationException();
319: }
320:
321: /**
322: * @see javax.mail.Message#setFlags(javax.mail.Flags, boolean)
323: */
324: public void setFlags(Flags arg0, boolean arg1)
325: throws MessagingException {
326: throw new UnsupportedOperationException();
327: }
328:
329: /**
330: * @see javax.mail.Message#setFrom()
331: */
332: public void setFrom() throws MessagingException {
333: throw new UnsupportedOperationException();
334: }
335:
336: /**
337: * @see javax.mail.Message#setFrom(javax.mail.Address)
338: */
339: public void setFrom(Address arg0) throws MessagingException {
340: throw new UnsupportedOperationException();
341: }
342:
343: /**
344: * @see javax.mail.Part#setHeader(java.lang.String, java.lang.String)
345: */
346: public void setHeader(String arg0, String arg1)
347: throws MessagingException {
348: throw new UnsupportedOperationException();
349: }
350:
351: /**
352: * @see javax.mail.Message#setRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])
353: */
354: public void setRecipients(RecipientType arg0, Address[] arg1)
355: throws MessagingException {
356: throw new UnsupportedOperationException();
357: }
358:
359: /**
360: * @see javax.mail.Message#setSentDate(java.util.Date)
361: */
362: public void setSentDate(Date arg0) throws MessagingException {
363: throw new UnsupportedOperationException();
364: }
365:
366: /**
367: * @see javax.mail.Message#setSubject(java.lang.String)
368: */
369: public void setSubject(String arg0) throws MessagingException {
370: throw new UnsupportedOperationException();
371: }
372:
373: /**
374: * @see javax.mail.Part#setText(java.lang.String)
375: */
376: public void setText(String arg0) throws MessagingException {
377: throw new UnsupportedOperationException();
378: }
379:
380: /**
381: * @see javax.mail.Part#writeTo(java.io.OutputStream)
382: */
383: public void writeTo(OutputStream arg0) throws IOException,
384: MessagingException {
385: throw new UnsupportedOperationException();
386: }
387: }
|