src/java.desktop/share/classes/javax/print/attribute/AttributeSetUtilities.java
author darcy
Tue, 24 Sep 2019 18:25:54 -0700
changeset 58309 c6f8b2c3dc66
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
     2
 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.print.attribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    31
 * Class {@code AttributeSetUtilities} provides static methods for manipulating
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    32
 * {@code AttributeSets}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <ul>
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    34
 *   <li>Methods for creating unmodifiable and synchronized views of attribute
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    35
 *   sets.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    36
 *   <li>operations useful for building implementations of interface
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    37
 *   {@link AttributeSet AttributeSet}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * </ul>
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    39
 * An <b>unmodifiable view</b> <i>U</i> of an {@code AttributeSet} <i>S</i>
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    40
 * provides a client with "read-only" access to <i>S</i>. Query operations on
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    41
 * <i>U</i> "read through" to <i>S</i>; thus, changes in <i>S</i> are reflected
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    42
 * in <i>U</i>. However, any attempt to modify <i>U</i>, results in an
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    43
 * {@code UnmodifiableSetException}. The unmodifiable view object <i>U</i> will
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    44
 * be serializable if the attribute set object <i>S</i> is serializable.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    45
 * <p>
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    46
 * A <b>synchronized view</b> <i>V</i> of an attribute set <i>S</i> provides a
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    47
 * client with synchronized (multiple thread safe) access to <i>S</i>. Each
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    48
 * operation of <i>V</i> is synchronized using <i>V</i> itself as the lock
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    49
 * object and then merely invokes the corresponding operation of <i>S</i>. In
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    50
 * order to guarantee mutually exclusive access, it is critical that all access
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    51
 * to <i>S</i> is accomplished through <i>V</i>. The synchronized view object
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    52
 * <i>V</i> will be serializable if the attribute set object <i>S</i> is
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    53
 * serializable.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    54
 * <p>
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    55
 * As mentioned in the package description of {@code javax.print}, a
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    56
 * {@code null} reference parameter to methods is incorrect unless explicitly
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    57
 * documented on the method as having a meaningful interpretation. Usage to the
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    58
 * contrary is incorrect coding and may result in a run time exception either
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    59
 * immediately or at some later time. {@code IllegalArgumentException} and
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    60
 * {@code NullPointerException} are examples of typical and acceptable run time
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    61
 * exceptions for such cases.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    63
 * @author Alan Kaminsky
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
public final class AttributeSetUtilities {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    67
    /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    68
     * Suppress default constructor, ensuring non-instantiability.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private AttributeSetUtilities() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    74
     * Unmodifiable view of {@code AttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    75
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    76
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    77
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private static class UnmodifiableAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        implements AttributeSet, Serializable {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    80
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    81
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    82
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    83
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
    84
        private static final long serialVersionUID = -6131802583863447813L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    86
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    87
         * The attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    88
         */
58309
c6f8b2c3dc66 8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes
darcy
parents: 47216
diff changeset
    89
        @SuppressWarnings("serial") // Not statically typed as Serializable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        private AttributeSet attrset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    92
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    93
         * Constructs unmodifiable view of the underlying attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    94
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
    95
         * @param  attributeSet the attribute set
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        public UnmodifiableAttributeSet(AttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            attrset = attributeSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        public Attribute get(Class<?> key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            return attrset.get(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        public boolean add(Attribute attribute) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            throw new UnmodifiableSetException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        public synchronized boolean remove(Class<?> category) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            throw new UnmodifiableSetException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        public boolean remove(Attribute attribute) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            throw new UnmodifiableSetException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        public boolean containsKey(Class<?> category) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            return attrset.containsKey(category);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        public boolean containsValue(Attribute attribute) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            return attrset.containsValue(attribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        public boolean addAll(AttributeSet attributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            throw new UnmodifiableSetException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        public int size() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            return attrset.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        public Attribute[] toArray() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            return attrset.toArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        public void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            throw new UnmodifiableSetException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        public boolean isEmpty() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            return attrset.isEmpty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            return attrset.equals (o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            return attrset.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   156
     * Unmodifiable view of {@code DocAttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   157
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   158
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   159
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    private static class UnmodifiableDocAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        extends UnmodifiableAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        implements DocAttributeSet, Serializable {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   163
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   164
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   165
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   166
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   167
        private static final long serialVersionUID = -6349408326066898956L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   169
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   170
         * Constructs a new unmodifiable doc attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   171
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   172
         * @param  attributeSet the doc attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   173
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        public UnmodifiableDocAttributeSet(DocAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            super (attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   181
     * Unmodifiable view of {@code PrintRequestAttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   182
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   183
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   184
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    private static class UnmodifiablePrintRequestAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        extends UnmodifiableAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        implements PrintRequestAttributeSet, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   189
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   190
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   191
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   192
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   193
        private static final long serialVersionUID = 7799373532614825073L;
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   194
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   195
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   196
         * Constructs a new unmodifiable print request attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   197
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   198
         * @param  attributeSet the print request attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   199
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        public UnmodifiablePrintRequestAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            (PrintRequestAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            super (attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   208
     * Unmodifiable view of {@code PrintJobAttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   209
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   210
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   211
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    private static class UnmodifiablePrintJobAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        extends UnmodifiableAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        implements PrintJobAttributeSet, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   216
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   217
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   218
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   219
        private static final long serialVersionUID = -8002245296274522112L;
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   220
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   221
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   222
         * Constructs a new unmodifiable print job attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   223
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   224
         * @param  attributeSet the print job attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   225
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        public UnmodifiablePrintJobAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            (PrintJobAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            super (attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   234
     * Unmodifiable view of {@code PrintServiceAttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   235
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   236
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   237
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    private static class UnmodifiablePrintServiceAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        extends UnmodifiableAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        implements PrintServiceAttributeSet, Serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   242
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   243
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   244
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   245
        private static final long serialVersionUID = -7112165137107826819L;
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   246
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   247
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   248
         * Constructs a new unmodifiable print service attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   249
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   250
         * @param  attributeSet the print service attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   251
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        public UnmodifiablePrintServiceAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            (PrintServiceAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            super (attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * Creates an unmodifiable view of the given attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   262
     * @param  attributeSet underlying attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   263
     * @return unmodifiable view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   264
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public static AttributeSet unmodifiableView(AttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        return new UnmodifiableAttributeSet(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Creates an unmodifiable view of the given doc attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   277
     * @param  attributeSet underlying doc attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   278
     * @return unmodifiable view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   279
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    public static DocAttributeSet unmodifiableView
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        (DocAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        return new UnmodifiableDocAttributeSet(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * Creates an unmodifiable view of the given print request attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   292
     * @param  attributeSet underlying print request attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   293
     * @return unmodifiable view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   294
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    public static PrintRequestAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        unmodifiableView(PrintRequestAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        return new UnmodifiablePrintRequestAttributeSet(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * Creates an unmodifiable view of the given print job attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   307
     * @param  attributeSet underlying print job attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   308
     * @return unmodifiable view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   309
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public static PrintJobAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        unmodifiableView(PrintJobAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        return new UnmodifiablePrintJobAttributeSet(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * Creates an unmodifiable view of the given print service attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   322
     * @param  attributeSet underlying print service attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   323
     * @return unmodifiable view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   324
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    public static PrintServiceAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        unmodifiableView(PrintServiceAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        return new UnmodifiablePrintServiceAttributeSet (attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   335
     * Synchronized view of {@code AttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   336
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   337
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   338
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    private static class SynchronizedAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                        implements AttributeSet, Serializable {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   341
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   342
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   343
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   344
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   345
        private static final long serialVersionUID = 8365731020128564925L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   347
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   348
         * The attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   349
         */
58309
c6f8b2c3dc66 8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes
darcy
parents: 47216
diff changeset
   350
        @SuppressWarnings("serial") // Not statically typed as Serializable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        private AttributeSet attrset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   353
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   354
         * Constructs a new synchronized attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   355
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   356
         * @param  attributeSet the attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   357
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        public SynchronizedAttributeSet(AttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            attrset = attributeSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        public synchronized Attribute get(Class<?> category) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            return attrset.get(category);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        public synchronized boolean add(Attribute attribute) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            return attrset.add(attribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        public synchronized boolean remove(Class<?> category) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            return attrset.remove(category);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        public synchronized boolean remove(Attribute attribute) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            return attrset.remove(attribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        public synchronized boolean containsKey(Class<?> category) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            return attrset.containsKey(category);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        public synchronized boolean containsValue(Attribute attribute) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            return attrset.containsValue(attribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        public synchronized boolean addAll(AttributeSet attributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            return attrset.addAll(attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        public synchronized int size() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            return attrset.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        public synchronized Attribute[] toArray() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            return attrset.toArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        public synchronized void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            attrset.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        public synchronized boolean isEmpty() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            return attrset.isEmpty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        public synchronized boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            return attrset.equals (o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        public synchronized int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            return attrset.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   416
     * Synchronized view of {@code DocAttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   417
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   418
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   419
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    private static class SynchronizedDocAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        extends SynchronizedAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        implements DocAttributeSet, Serializable {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   423
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   424
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   425
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   426
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   427
        private static final long serialVersionUID = 6455869095246629354L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   429
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   430
         * Constructs a new synchronized doc attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   431
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   432
         * @param  attributeSet the doc attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   433
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        public SynchronizedDocAttributeSet(DocAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            super(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   440
     * Synchronized view of {@code PrintRequestAttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   441
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   442
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   443
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    private static class SynchronizedPrintRequestAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        extends SynchronizedAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        implements PrintRequestAttributeSet, Serializable {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   447
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   448
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   449
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   450
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   451
        private static final long serialVersionUID = 5671237023971169027L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   453
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   454
         * Constructs a new synchronized print request attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   455
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   456
         * @param  attributeSet the print request attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   457
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        public SynchronizedPrintRequestAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            (PrintRequestAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            super(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   465
     * Synchronized view of {@code PrintJobAttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   466
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   467
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   468
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    private static class SynchronizedPrintJobAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        extends SynchronizedAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        implements PrintJobAttributeSet, Serializable {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   472
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   473
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   474
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   475
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   476
        private static final long serialVersionUID = 2117188707856965749L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   478
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   479
         * Constructs a new synchronized print job attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   480
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   481
         * @param  attributeSet the print job attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   482
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        public SynchronizedPrintJobAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            (PrintJobAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            super(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   490
     * Synchronized view of {@code PrintServiceAttributeSet}.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   491
     *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   492
     * @serial include
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   493
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    private static class SynchronizedPrintServiceAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        extends SynchronizedAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        implements PrintServiceAttributeSet, Serializable {
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   497
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   498
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   499
         * Use serialVersionUID from JDK 1.4 for interoperability.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   500
         */
22950
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   501
        private static final long serialVersionUID = -2830705374001675073L;
8d8e9ffdf855 8034050: Fix serial lint warnings in javax.print
darcy
parents: 5506
diff changeset
   502
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   503
        /**
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   504
         * Constructs a new synchronized print service attribute set.
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   505
         *
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   506
         * @param  attributeSet the print service attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   507
         */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        public SynchronizedPrintServiceAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            (PrintServiceAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            super(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * Creates a synchronized view of the given attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   517
     * @param  attributeSet underlying attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   518
     * @return synchronized view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   519
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    public static AttributeSet synchronizedView
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        (AttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        return new SynchronizedAttributeSet(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * Creates a synchronized view of the given doc attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   532
     * @param  attributeSet underlying doc attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   533
     * @return synchronized view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   534
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    public static DocAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        synchronizedView(DocAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        return new SynchronizedDocAttributeSet(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * Creates a synchronized view of the given print request attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   547
     * @param  attributeSet underlying print request attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   548
     * @return synchronized view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   549
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    public static PrintRequestAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        synchronizedView(PrintRequestAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        return new SynchronizedPrintRequestAttributeSet(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * Creates a synchronized view of the given print job attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   562
     * @param  attributeSet underlying print job attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   563
     * @return synchronized view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   564
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    public static PrintJobAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        synchronizedView(PrintJobAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        return new SynchronizedPrintJobAttributeSet(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * Creates a synchronized view of the given print service attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   577
     * @param  attributeSet underlying print service attribute set
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   578
     * @return synchronized view of {@code attributeSet}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   579
     * @throws NullPointerException if {@code attributeSet} is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    public static PrintServiceAttributeSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        synchronizedView(PrintServiceAttributeSet attributeSet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        if (attributeSet == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        return new SynchronizedPrintServiceAttributeSet(attributeSet);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   590
     * Verify that the given object is a {@link Class Class} that implements the
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   591
     * given interface, which is assumed to be interface
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   592
     * {@link Attribute Attribute} or a subinterface thereof.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   594
     * @param  object {@code Object} to test
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   595
     * @param  interfaceName interface the object must implement
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   596
     * @return if {@code object} is a {@link Class Class} that implements
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   597
     *         {@code interfaceName}, {@code object} is returned downcast to
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   598
     *         type {@link Class Class}; otherwise an exception is thrown
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   599
     * @throws NullPointerException if {@code object} is {@code null}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   600
     * @throws ClassCastException if {@code object} is not a
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   601
     *         {@link Class Class} that implements {@code interfaceName}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    public static Class<?>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        verifyAttributeCategory(Object object, Class<?> interfaceName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
25093
8ec5ec01740e 8042864: Fix raw and unchecked warnings in javax.print
darcy
parents: 22950
diff changeset
   606
        Class<?> result = (Class<?>) object;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        if (interfaceName.isAssignableFrom (result)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            throw new ClassCastException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * Verify that the given object is an instance of the given interface, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * is assumed to be interface {@link Attribute Attribute} or a subinterface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * thereof.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   620
     * @param  object {@code Object} to test
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   621
     * @param  interfaceName interface of which the object must be an instance
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   622
     * @return if {@code object} is an instance of {@code interfaceName},
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   623
     *         {@code object} is returned downcast to type
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   624
     *         {@link Attribute Attribute}; otherwise an exception is thrown
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   625
     * @throws NullPointerException if {@code object} is {@code null}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   626
     * @throws ClassCastException if {@code object} is not an instance of
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   627
     *         {@code interfaceName}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    public static Attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        verifyAttributeValue(Object object, Class<?> interfaceName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        if (object == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        else if (interfaceName.isInstance (object)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            return (Attribute) object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            throw new ClassCastException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    /**
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   643
     * Verify that the given attribute category object is equal to the category
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   644
     * of the given attribute value object. If so, this method returns doing
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   645
     * nothing. If not, this method throws an exception.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     *
47196
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   647
     * @param  category attribute category to test
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   648
     * @param  attribute attribute value to test
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   649
     * @throws NullPointerException if the {@code category} or {@code attribute}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   650
     *         are {@code null}
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   651
     * @throws IllegalArgumentException if the {@code category} is not equal to
a3211bb4daff 8184435: Cleanup of javadoc in javax.print package
serb
parents: 35667
diff changeset
   652
     *         the category of the {@code attribute}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    public static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        verifyCategoryForValue(Class<?> category, Attribute attribute) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        if (!category.equals (attribute.getCategory())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
}