1 /*
2 * Copyright (c) 2000, 2003, 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
33 import java.util.Map;
34 import java.util.NoSuchElementException;
35 import java.util.Set;
36 import java.util.Vector;
37
38 /**
39 * Class MimeType encapsulates a Multipurpose Internet Mail Extensions (MIME)
40 * media type as defined in <A HREF="http://www.ietf.org/rfc/rfc2045.txt">RFC
41 * 2045</A> and <A HREF="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</A>. A
42 * MIME type object is part of a {@link DocFlavor DocFlavor} object and
43 * specifies the format of the print data.
44 * <P>
45 * Class MimeType is similar to the like-named
46 * class in package {@link java.awt.datatransfer java.awt.datatransfer}. Class
47 * java.awt.datatransfer.MimeType is not used in the Jini Print Service API
48 * for two reasons:
49 * <OL TYPE=1>
50 * <LI>
51 * Since not all Java profiles include the AWT, the Jini Print Service should
52 * not depend on an AWT class.
53 * <P>
54 * <LI>
55 * The implementation of class java.awt.datatransfer.MimeType does not
56 * guarantee
57 * that equivalent MIME types will have the same serialized representation.
58 * Thus, since the Jini Lookup Service (JLUS) matches service attributes based
59 * on equality of serialized representations, JLUS searches involving MIME
60 * types encapsulated in class java.awt.datatransfer.MimeType may incorrectly
61 * fail to match.
62 * </OL>
63 * <P>
64 * Class MimeType's serialized representation is based on the following
65 * canonical form of a MIME type string. Thus, two MIME types that are not
66 * identical but that are equivalent (that have the same canonical form) will
67 * be considered equal by the JLUS's matching algorithm.
68 * <UL>
69 * <LI> The media type, media subtype, and parameters are retained, but all
70 * comments and whitespace characters are discarded.
71 * <LI> The media type, media subtype, and parameter names are converted to
72 * lowercase.
73 * <LI> The parameter values retain their original case, except a charset
74 * parameter value for a text media type is converted to lowercase.
75 * <LI> Quote characters surrounding parameter values are removed.
76 * <LI> Quoting backslash characters inside parameter values are removed.
77 * <LI> The parameters are arranged in ascending order of parameter name.
78 * </UL>
79 * <P>
80 *
81 * @author Alan Kaminsky
82 */
83 class MimeType implements Serializable, Cloneable {
84
85 private static final long serialVersionUID = -2785720609362367683L;
86
87 /**
88 * Array of strings that hold pieces of this MIME type's canonical form.
89 * If the MIME type has <I>n</I> parameters, <I>n</I> >= 0, then the
90 * strings in the array are:
91 * <BR>Index 0 -- Media type.
92 * <BR>Index 1 -- Media subtype.
93 * <BR>Index 2<I>i</I>+2 -- Name of parameter <I>i</I>,
94 * <I>i</I>=0,1,...,<I>n</I>-1.
95 * <BR>Index 2<I>i</I>+3 -- Value of parameter <I>i</I>,
96 * <I>i</I>=0,1,...,<I>n</I>-1.
97 * <BR>Parameters are arranged in ascending order of parameter name.
98 * @serial
99 */
|
1 /*
2 * Copyright (c) 2000, 2017, 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
33 import java.util.Map;
34 import java.util.NoSuchElementException;
35 import java.util.Set;
36 import java.util.Vector;
37
38 /**
39 * Class MimeType encapsulates a Multipurpose Internet Mail Extensions (MIME)
40 * media type as defined in <A HREF="http://www.ietf.org/rfc/rfc2045.txt">RFC
41 * 2045</A> and <A HREF="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</A>. A
42 * MIME type object is part of a {@link DocFlavor DocFlavor} object and
43 * specifies the format of the print data.
44 * <P>
45 * Class MimeType is similar to the like-named
46 * class in package {@link java.awt.datatransfer java.awt.datatransfer}. Class
47 * java.awt.datatransfer.MimeType is not used in the Jini Print Service API
48 * for two reasons:
49 * <OL TYPE=1>
50 * <LI>
51 * Since not all Java profiles include the AWT, the Jini Print Service should
52 * not depend on an AWT class.
53 * <LI>
54 * The implementation of class java.awt.datatransfer.MimeType does not
55 * guarantee
56 * that equivalent MIME types will have the same serialized representation.
57 * Thus, since the Jini Lookup Service (JLUS) matches service attributes based
58 * on equality of serialized representations, JLUS searches involving MIME
59 * types encapsulated in class java.awt.datatransfer.MimeType may incorrectly
60 * fail to match.
61 * </OL>
62 * <P>
63 * Class MimeType's serialized representation is based on the following
64 * canonical form of a MIME type string. Thus, two MIME types that are not
65 * identical but that are equivalent (that have the same canonical form) will
66 * be considered equal by the JLUS's matching algorithm.
67 * <UL>
68 * <LI> The media type, media subtype, and parameters are retained, but all
69 * comments and whitespace characters are discarded.
70 * <LI> The media type, media subtype, and parameter names are converted to
71 * lowercase.
72 * <LI> The parameter values retain their original case, except a charset
73 * parameter value for a text media type is converted to lowercase.
74 * <LI> Quote characters surrounding parameter values are removed.
75 * <LI> Quoting backslash characters inside parameter values are removed.
76 * <LI> The parameters are arranged in ascending order of parameter name.
77 * </UL>
78 *
79 * @author Alan Kaminsky
80 */
81 class MimeType implements Serializable, Cloneable {
82
83 private static final long serialVersionUID = -2785720609362367683L;
84
85 /**
86 * Array of strings that hold pieces of this MIME type's canonical form.
87 * If the MIME type has <I>n</I> parameters, <I>n</I> >= 0, then the
88 * strings in the array are:
89 * <BR>Index 0 -- Media type.
90 * <BR>Index 1 -- Media subtype.
91 * <BR>Index 2<I>i</I>+2 -- Name of parameter <I>i</I>,
92 * <I>i</I>=0,1,...,<I>n</I>-1.
93 * <BR>Index 2<I>i</I>+3 -- Value of parameter <I>i</I>,
94 * <I>i</I>=0,1,...,<I>n</I>-1.
95 * <BR>Parameters are arranged in ascending order of parameter name.
96 * @serial
97 */
|