Skip to content

Package: EncodingAware

EncodingAware

Coverage

1: /*
2: * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package jakarta.mail;
18:
19: /**
20: * A {@link jakarta.activation.DataSource DataSource} that also implements
21: * <code>EncodingAware</code> may specify the Content-Transfer-Encoding
22: * to use for its data. Valid Content-Transfer-Encoding values specified
23: * by RFC 2045 are "7bit", "8bit", "quoted-printable", "base64", and "binary".
24: * <p>
25: * For example, a {@link jakarta.activation.FileDataSource FileDataSource}
26: * could be created that forces all files to be base64 encoded:
27: * <blockquote><pre>
28: * public class Base64FileDataSource extends FileDataSource
29: *                                         implements EncodingAware {
30: *         public Base64FileDataSource(File file) {
31: *          super(file);
32: * }
33: *
34: *         // implements EncodingAware.getEncoding()
35: *         public String getEncoding() {
36: *          return "base64";
37: * }
38: * }
39: * </pre></blockquote>
40: *
41: * @author Bill Shannon
42: * @since JavaMail 1.5
43: */
44:
45: public interface EncodingAware {
46:
47: /**
48: * Return the MIME Content-Transfer-Encoding to use for this data,
49: * or null to indicate that an appropriate value should be chosen
50: * by the caller.
51: *
52: * @return the Content-Transfer-Encoding value, or null
53: */
54: String getEncoding();
55: }