KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > util > mail > handlers > multipart_report


1 /***********************************************************************
2  * Copyright (c) 2003-2004 The Apache Software Foundation. *
3  * All rights reserved. *
4  * ------------------------------------------------------------------- *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you *
6  * may not use this file except in compliance with the License. You *
7  * may obtain a copy of the License at: *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
14  * implied. See the License for the specific language governing *
15  * permissions and limitations under the License. *
16  ***********************************************************************/

17 package org.apache.james.util.mail.handlers;
18
19 import java.io.IOException JavaDoc;
20 import java.io.OutputStream JavaDoc;
21
22 import javax.activation.ActivationDataFlavor JavaDoc;
23 import javax.activation.DataSource JavaDoc;
24 import javax.mail.MessagingException JavaDoc;
25
26 import org.apache.james.util.mail.MimeMultipartReport;
27
28 /**
29  * <p>Data Content Handler for...</p>
30  * <dl>
31  * <dt>MIME type name</dt><dd>multipart</dd>
32  * <dt>MIME subtype name</dt><dd>report</dd>
33  * </dl>
34  */

35 public class multipart_report extends AbstractDataContentHandler
36 {
37     /**
38      * Default constructor.
39      */

40     public multipart_report()
41     {
42         super();
43     }
44
45     /**
46      * @see org.apache.james.util.mail.handlers.AbstractDataContentHandler#computeDataFlavor()
47      */

48     protected ActivationDataFlavor JavaDoc computeDataFlavor()
49     {
50         return new ActivationDataFlavor JavaDoc(MimeMultipartReport.class,
51                 "multipart/report", "Multipart Report");
52     }
53
54     /**
55      * @see javax.activation.DataContentHandler#writeTo(java.lang.Object,
56      * java.lang.String, java.io.OutputStream)
57      */

58     public void writeTo(Object JavaDoc aPart, String JavaDoc aMimeType, OutputStream JavaDoc aStream)
59             throws IOException JavaDoc
60     {
61         if (!(aPart instanceof MimeMultipartReport))
62             throw new IOException JavaDoc("Type \"" + aPart.getClass().getName()
63                     + "\" is not supported.");
64         try
65         {
66             ((MimeMultipartReport) aPart).writeTo(aStream);
67         }
68         catch (MessagingException JavaDoc e)
69         {
70             throw new IOException JavaDoc(e.getMessage());
71         }
72     }
73
74     /**
75      * @see org.apache.james.util.mail.handlers.AbstractDataContentHandler#computeContent(javax.activation.DataSource)
76      */

77     protected Object JavaDoc computeContent(DataSource JavaDoc aDataSource)
78             throws MessagingException JavaDoc
79     {
80         return new MimeMultipartReport(aDataSource);
81     }
82 }
83
Popular Tags