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
23 * questions.
24 */
25
26package javax.print.attribute.standard;
27
28import java.util.Locale;
29
30import javax.print.attribute.Attribute;
31import javax.print.attribute.PrintServiceAttribute;
32import javax.print.attribute.TextSyntax;
33
34/**
35 * Class {@code PrinterMakeAndModel} is a printing attribute class, a text
36 * attribute, that the make and model of the printer.
37 * <p>
38 * <b>IPP Compatibility:</b> The string value gives the IPP name value. The
39 * locale gives the IPP natural language. The category name returned by
40 * {@code getName()} gives the IPP attribute name.
41 *
42 * @author Alan Kaminsky
43 */
44public final class PrinterMakeAndModel extends TextSyntax
45        implements PrintServiceAttribute {
46
47    /**
48     * Use serialVersionUID from JDK 1.4 for interoperability.
49     */
50    private static final long serialVersionUID = 4580461489499351411L;
51
52    /**
53     * Constructs a new printer make and model attribute with the given make and
54     * model string and locale.
55     *
56     * @param  makeAndModel printer make and model string
57     * @param  locale natural language of the text string. {@code null} is
58     *         interpreted to mean the default locale as returned by
59     *         {@code Locale.getDefault()}
60     * @throws NullPointerException if {@code makeAndModel} is {@code null}
61     */
62    public PrinterMakeAndModel(String makeAndModel, Locale locale) {
63        super (makeAndModel, locale);
64    }
65
66    /**
67     * Returns whether this printer make and model attribute is equivalent to
68     * the passed in object. To be equivalent, all of the following conditions
69     * must be true:
70     * <ol type=1>
71     *   <li>{@code object} is not {@code null}.
72     *   <li>{@code object} is an instance of class {@code PrinterMakeAndModel}.
73     *   <li>This printer make and model attribute's underlying string and
74     *   {@code object}'s underlying string are equal.
75     *   <li>This printer make and model attribute's locale and {@code object}'s
76     *   locale are equal.
77     * </ol>
78     *
79     * @param  object {@code Object} to compare to
80     * @return {@code true} if {@code object} is equivalent to this printer make
81     *         and model attribute, {@code false} otherwise
82     */
83    public boolean equals(Object object) {
84        return (super.equals(object) &&
85                object instanceof PrinterMakeAndModel);
86    }
87
88    /**
89     * Get the printing attribute class which is to be used as the "category"
90     * for this printing attribute value.
91     * <p>
92     * For class {@code PrinterMakeAndModel}, the category is class
93     * {@code PrinterMakeAndModel} itself.
94     *
95     * @return printing attribute class (category), an instance of class
96     *         {@link Class java.lang.Class}
97     */
98    public final Class<? extends Attribute> getCategory() {
99        return PrinterMakeAndModel.class;
100    }
101
102    /**
103     * Get the name of the category of which this attribute value is an
104     * instance.
105     * <p>
106     * For class {@code PrinterMakeAndModel}, the category name is
107     * {@code "printer-make-and-model"}.
108     *
109     * @return attribute category name
110     */
111    public final String getName() {
112        return "printer-make-and-model";
113    }
114}
115