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