1 /* 2 * Copyright (c) 2001, 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.net.URI; 28 import java.util.Locale; 29 30 import javax.print.attribute.Attribute; 31 import javax.print.attribute.URISyntax; 32 import javax.print.attribute.PrintServiceAttribute; 33 34 /** 35 * Class PrinterURI is a printing attribute class, a URI, that specifies the 36 * globally unique name of a printer. If it has such a name, an administrator 37 * determines a printer's URI and sets this attribute to that name. 38 * <P> 39 * <B>IPP Compatibility:</B> This implements the 40 * IPP printer-uri attribute. The string form returned by 41 * {@code toString()} gives the IPP printer-uri value. 42 * The category name returned by {@code getName()} 43 * gives the IPP attribute name. 44 * 45 * @author Robert Herriot 46 */ 47 48 public final class PrinterURI extends URISyntax 49 implements PrintServiceAttribute { 50 51 private static final long serialVersionUID = 7923912792485606497L; 52 53 /** 54 * Constructs a new PrinterURI attribute with the specified URI. 55 * 56 * @param uri URI of the printer 57 * 58 * @exception NullPointerException 59 * (unchecked exception) Thrown if {@code uri} is null. 60 */ 61 public PrinterURI(URI uri) { 62 super (uri); 63 } 64 65 /** 66 * Returns whether this printer name attribute is equivalent to the passed 67 * in object. To be equivalent, all of the following conditions must be 68 * true: 69 * <OL TYPE=1> 70 * <LI> 71 * {@code object} is not null. 72 * <LI> 73 * {@code object} is an instance of class PrinterURI. 74 * <LI> 75 * This PrinterURI attribute's underlying URI and 76 * {@code object}'s underlying URI are equal. 77 * </OL> 78 * 79 * @param object Object to compare to. 80 * 81 * @return True if {@code object} is equivalent to this PrinterURI 82 * attribute, false otherwise. 83 */ 84 public boolean equals(Object object) { 85 return (super.equals(object) && object instanceof PrinterURI); 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 PrinterURI and any vendor-defined subclasses, the category is 93 * class PrinterURI itself. 94 * 95 * @return Printing attribute class (category), an instance of class 96 * {@link java.lang.Class java.lang.Class}. 97 */ 98 public final Class<? extends Attribute> getCategory() { 99 return PrinterURI.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 PrinterURI and any vendor-defined subclasses, the category 107 * name is {@code "printer-uri"}. 108 * 109 * @return Attribute category name. 110 */ 111 public final String getName() { 112 return "printer-uri"; 113 } 114 115 } | 1 /* 2 * Copyright (c) 2001, 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.net.URI; 29 30 import javax.print.attribute.Attribute; 31 import javax.print.attribute.PrintServiceAttribute; 32 import javax.print.attribute.URISyntax; 33 34 /** 35 * Class {@code PrinterURI} is a printing attribute class, a {@code URI}, that 36 * specifies the globally unique name of a printer. If it has such a name, an 37 * administrator determines a printer's {@code URI} and sets this attribute to 38 * that name. 39 * <p> 40 * <b>IPP Compatibility:</b> This implements the IPP printer-uri attribute. The 41 * string form returned by {@code toString()} gives the IPP printer-uri value. 42 * The category name returned by {@code getName()} gives the IPP attribute name. 43 * 44 * @author Robert Herriot 45 */ 46 public final class PrinterURI extends URISyntax 47 implements PrintServiceAttribute { 48 49 /** 50 * Use serialVersionUID from JDK 1.4 for interoperability. 51 */ 52 private static final long serialVersionUID = 7923912792485606497L; 53 54 /** 55 * Constructs a new {@code PrinterURI} attribute with the specified 56 * {@code URI}. 57 * 58 * @param uri {@code URI} of the printer 59 * @throws NullPointerException if {@code uri} is {@code null} 60 */ 61 public PrinterURI(URI uri) { 62 super (uri); 63 } 64 65 /** 66 * Returns whether this printer name attribute is equivalent to the passed 67 * in object. To be equivalent, all of the following conditions must be 68 * true: 69 * <ol type=1> 70 * <li>{@code object} is not {@code null}. 71 * <li>{@code object} is an instance of class {@code PrinterURI}. 72 * <li>This {@code PrinterURI} attribute's underlying {@code URI} and 73 * {@code object}'s underlying {@code URI} are equal. 74 * </ol> 75 * 76 * @param object {@code Object} to compare to 77 * @return {@code true} if {@code object} is equivalent to this 78 * {@code PrinterURI} attribute, {@code false} otherwise 79 */ 80 public boolean equals(Object object) { 81 return (super.equals(object) && object instanceof PrinterURI); 82 } 83 84 /** 85 * Get the printing attribute class which is to be used as the "category" 86 * for this printing attribute value. 87 * <p> 88 * For class {@code PrinterURI} and any vendor-defined subclasses, the 89 * category is class {@code PrinterURI} itself. 90 * 91 * @return printing attribute class (category), an instance of class 92 * {@link Class java.lang.Class} 93 */ 94 public final Class<? extends Attribute> getCategory() { 95 return PrinterURI.class; 96 } 97 98 /** 99 * Get the name of the category of which this attribute value is an 100 * instance. 101 * <p> 102 * For class {@code PrinterURI} and any vendor-defined subclasses, the 103 * category name is {@code "printer-uri"}. 104 * 105 * @return attribute category name 106 */ 107 public final String getName() { 108 return "printer-uri"; 109 } 110 } |