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 }