1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * @(#)MimeBodyPart.java 1.52 03/02/12
28 */
29
30
31
32 package com.sun.xml.internal.messaging.saaj.packaging.mime.internet;
33
34
35 import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
36 import com.sun.xml.internal.messaging.saaj.packaging.mime.util.OutputUtil;
37 import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
38 import com.sun.xml.internal.messaging.saaj.util.FinalArrayList;
39
40 import javax.activation.DataHandler;
41 import java.io.BufferedInputStream;
42 import java.io.ByteArrayInputStream;
43 import java.io.IOException;
44 import java.io.InputStream;
45 import java.io.OutputStream;
46 import java.io.UnsupportedEncodingException;
47 import java.util.List;
48 import javax.activation.DataSource;
49 import com.sun.xml.internal.org.jvnet.mimepull.MIMEPart;
50
51 /**
52 * This class represents a MIME body part.
53 * MimeBodyParts are contained in <code>MimeMultipart</code>
54 * objects. <p>
1024 *
1025 * @param name header name
1026 * @param value header value
1027 * @see MimeUtility
1028 */
1029 public void addHeader(String name, String value) {
1030 headers.addHeader(name, value);
1031 }
1032
1033 /**
1034 * Remove all headers with this name.
1035 */
1036 public void removeHeader(String name) {
1037 headers.removeHeader(name);
1038 }
1039
1040 /**
1041 * Return all the headers from this Message as an Enumeration of
1042 * Header objects.
1043 */
1044 public FinalArrayList<hdr> getAllHeaders() {
1045 return headers.getAllHeaders();
1046 }
1047
1048
1049 /**
1050 * Add a header line to this body part
1051 */
1052 public void addHeaderLine(String line) {
1053 headers.addHeaderLine(line);
1054 }
1055
1056 /**
1057 * Examine the content of this body part and update the appropriate
1058 * MIME headers. Typical headers that get set here are
1059 * <code>Content-Type</code> and <code>Content-Transfer-Encoding</code>.
1060 * Headers might need to be updated in two cases:
1061 *
1062 * <br>
1063 * - A message being crafted by a mail application will certainly
1064 * need to activate this method at some point to fill up its internal
|
1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * @(#)MimeBodyPart.java 1.52 03/02/12
28 */
29
30
31
32 package com.sun.xml.internal.messaging.saaj.packaging.mime.internet;
33
34
35 import com.sun.xml.internal.messaging.saaj.packaging.mime.Header;
36 import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
37 import com.sun.xml.internal.messaging.saaj.packaging.mime.util.OutputUtil;
38 import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
39 import com.sun.xml.internal.messaging.saaj.util.FinalArrayList;
40
41 import javax.activation.DataHandler;
42 import java.io.BufferedInputStream;
43 import java.io.ByteArrayInputStream;
44 import java.io.IOException;
45 import java.io.InputStream;
46 import java.io.OutputStream;
47 import java.io.UnsupportedEncodingException;
48 import java.util.List;
49 import javax.activation.DataSource;
50 import com.sun.xml.internal.org.jvnet.mimepull.MIMEPart;
51
52 /**
53 * This class represents a MIME body part.
54 * MimeBodyParts are contained in <code>MimeMultipart</code>
55 * objects. <p>
1025 *
1026 * @param name header name
1027 * @param value header value
1028 * @see MimeUtility
1029 */
1030 public void addHeader(String name, String value) {
1031 headers.addHeader(name, value);
1032 }
1033
1034 /**
1035 * Remove all headers with this name.
1036 */
1037 public void removeHeader(String name) {
1038 headers.removeHeader(name);
1039 }
1040
1041 /**
1042 * Return all the headers from this Message as an Enumeration of
1043 * Header objects.
1044 */
1045 public List<? extends Header> getAllHeaders() {
1046 return headers.getAllHeaders();
1047 }
1048
1049
1050 /**
1051 * Add a header line to this body part
1052 */
1053 public void addHeaderLine(String line) {
1054 headers.addHeaderLine(line);
1055 }
1056
1057 /**
1058 * Examine the content of this body part and update the appropriate
1059 * MIME headers. Typical headers that get set here are
1060 * <code>Content-Type</code> and <code>Content-Transfer-Encoding</code>.
1061 * Headers might need to be updated in two cases:
1062 *
1063 * <br>
1064 * - A message being crafted by a mail application will certainly
1065 * need to activate this method at some point to fill up its internal
|