blob: 1742860576a3532b64c09a35b1c9bc01cd534d6f [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2004 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25package javax.print.attribute.standard;
26
27import java.util.Locale;
28
29import javax.print.attribute.Attribute;
30import javax.print.attribute.TextSyntax;
31import javax.print.attribute.PrintServiceAttribute;
32
33/**
34 * Class PrinterLocation is a printing attribute class, a text attribute, that
35 * identifies the location of the device. This could include things like:
36 * <CODE>"in Room 123A, second floor of building XYZ"</CODE>.
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()</CODE> gives the IPP attribute name.
41 * <P>
42 *
43 * @author Alan Kaminsky
44 */
45public final class PrinterLocation extends TextSyntax
46 implements PrintServiceAttribute {
47
48 private static final long serialVersionUID = -1598610039865566337L;
49
50 /**
51 * Constructs a new printer location attribute with the given location and
52 * locale.
53 *
54 * @param location Printer location.
55 * @param locale Natural language of the text string. null
56 * is interpreted to mean the default locale as returned
57 * by <code>Locale.getDefault()</code>
58 *
59 * @exception NullPointerException
60 * (unchecked exception) Thrown if <CODE>location</CODE> is null.
61 */
62 public PrinterLocation(String location, Locale locale) {
63 super (location, locale);
64 }
65
66 /**
67 * Returns whether this printer location attribute is equivalent to the
68 * passed in object. To be equivalent, all of the following conditions
69 * must be true:
70 * <OL TYPE=1>
71 * <LI>
72 * <CODE>object</CODE> is not null.
73 * <LI>
74 * <CODE>object</CODE> is an instance of class PrinterLocation.
75 * <LI>
76 * This printer location attribute's underlying string and
77 * <CODE>object</CODE>'s underlying string are equal.
78 * <LI>
79 * This printer location attribute's locale and <CODE>object</CODE>'s
80 * locale are equal.
81 * </OL>
82 *
83 * @param object Object to compare to.
84 *
85 * @return True if <CODE>object</CODE> is equivalent to this printer
86 * location attribute, false otherwise.
87 */
88 public boolean equals(Object object) {
89 return (super.equals(object) && object instanceof PrinterLocation);
90 }
91
92 /**
93 * Get the printing attribute class which is to be used as the "category"
94 * for this printing attribute value.
95 * <P>
96 * For class PrinterLocation, the
97 * category is class PrinterLocation itself.
98 *
99 * @return Printing attribute class (category), an instance of class
100 * {@link java.lang.Class java.lang.Class}.
101 */
102 public final Class<? extends Attribute> getCategory() {
103 return PrinterLocation.class;
104 }
105
106 /**
107 * Get the name of the category of which this attribute value is an
108 * instance.
109 * <P>
110 * For class PrinterLocation, the
111 * category name is <CODE>"printer-location"</CODE>.
112 *
113 * @return Attribute category name.
114 */
115 public final String getName() {
116 return "printer-location";
117 }
118
119}