KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > mail > javamail > SmartMimeMessage


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

16
17 package org.springframework.mail.javamail;
18
19 import javax.activation.FileTypeMap JavaDoc;
20 import javax.mail.Session JavaDoc;
21 import javax.mail.internet.MimeMessage JavaDoc;
22
23 /**
24  * Special subclass of the standard JavaMail MimeMessage, carrying a
25  * default encoding to be used when populating the message and a default
26  * Java Activation FileTypeMap to be used for resolving attachment types.
27  *
28  * <p>Created by JavaMailSenderImpl in case of a specified default encoding
29  * and/or default FileTypeMap. Autodetected by MimeMessageHelper, which will
30  * use the carried encoding and FileTypeMap unless explicitly overridden.
31  *
32  * @author Juergen Hoeller
33  * @since 1.2
34  * @see JavaMailSenderImpl#createMimeMessage()
35  * @see MimeMessageHelper#getDefaultEncoding(javax.mail.internet.MimeMessage)
36  * @see MimeMessageHelper#getDefaultFileTypeMap(javax.mail.internet.MimeMessage)
37  */

38 class SmartMimeMessage extends MimeMessage JavaDoc {
39
40     private final String JavaDoc defaultEncoding;
41
42     private final FileTypeMap JavaDoc defaultFileTypeMap;
43
44
45     /**
46      * Create a new SmartMimeMessage.
47      * @param session the JavaMail Session to create the message for
48      * @param defaultEncoding the default encoding, or <code>null</code> if none
49      * @param defaultFileTypeMap the default FileTypeMap, or <code>null</code> if none
50      */

51     public SmartMimeMessage(Session JavaDoc session, String JavaDoc defaultEncoding, FileTypeMap JavaDoc defaultFileTypeMap) {
52         super(session);
53         this.defaultEncoding = defaultEncoding;
54         this.defaultFileTypeMap = defaultFileTypeMap;
55     }
56
57     /**
58      * Return the default encoding of this message, or <code>null</code> if none.
59      */

60     public String JavaDoc getDefaultEncoding() {
61         return defaultEncoding;
62     }
63
64     /**
65      * Return the default FileTypeMap of this message, or <code>null</code> if none.
66      */

67     public FileTypeMap JavaDoc getDefaultFileTypeMap() {
68         return defaultFileTypeMap;
69     }
70
71 }
72
Popular Tags