View Javadoc

1   /*****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  package org.apache.james.util.mail;
20  
21  import javax.activation.DataSource;
22  import javax.mail.MessagingException;
23  import javax.mail.internet.ContentType;
24  import javax.mail.internet.MimeMultipart;
25  
26  /***
27   * Class <code>MimeMultipartReport</code> implements JavaMail support
28   * for a MIME type of MimeMultipart with a subtype of report.
29   */
30  public class MimeMultipartReport extends MimeMultipart
31  {
32  
33      /***
34       * Default constructor
35       */
36      public MimeMultipartReport()
37      {
38          this("report");
39      }
40  
41      /***
42       * Constructs a MimeMultipartReport of the given subtype.
43       * @param subtype
44       */
45      public MimeMultipartReport(String subtype)
46      {
47          super(subtype);
48      }
49  
50      /***
51       * Constructs a MimeMultipartReport from the passed DataSource.
52       * @param aDataSource
53       * @throws javax.mail.MessagingException
54       */
55      public MimeMultipartReport(DataSource aDataSource) throws MessagingException
56      {
57          super(aDataSource);
58      }
59      
60      /***
61       * Sets the type of report.
62       * @param reportType
63       * @throws MessagingException
64       */
65      public void setReportType(String reportType) throws MessagingException
66      {
67          ContentType contentType = new ContentType(getContentType());
68          contentType.setParameter("report-type", reportType);
69          setContentType(contentType);
70      }
71      
72      /***
73       * Sets the content type
74       * @param aContentType
75       */
76      protected void setContentType(ContentType aContentType)
77      {
78          contentType = aContentType.toString();
79      }
80  
81  }