01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
20: import javax.mail.Session;
21: import javax.mail.internet.MimeMessage;
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 {
39:
40: private final String defaultEncoding;
41:
42: private final FileTypeMap defaultFileTypeMap;
43:
44: /**
45: * Create a new SmartMimeMessage.
46: * @param session the JavaMail Session to create the message for
47: * @param defaultEncoding the default encoding, or <code>null</code> if none
48: * @param defaultFileTypeMap the default FileTypeMap, or <code>null</code> if none
49: */
50: public SmartMimeMessage(Session session, String defaultEncoding,
51: FileTypeMap 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 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 getDefaultFileTypeMap() {
68: return defaultFileTypeMap;
69: }
70:
71: }
|