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 PrinterMessageFromOperator} is a printing attribute class, a
  36  * text attribute, that provides a message from an operator, system
  37  * administrator, or "intelligent" process to indicate to the end user
  38  * information about or status of the printer, such as why it is unavailable or
  39  * when it is expected to be available.
  40  * <p>
  41  * A Print Service's attribute set includes zero instances or one instance of a
  42  * {@code PrinterMessageFromOperator} attribute, not more than one instance. A
  43  * new {@code PrinterMessageFromOperator} attribute replaces an existing
  44  * {@code PrinterMessageFromOperator} attribute, if any. In other words,
  45  * {@code PrinterMessageFromOperator} is not intended to be a history log. If it
  46  * wishes, the client can detect changes to a Print Service's
  47  * {@code PrinterMessageFromOperator} attribute and maintain the client's own
  48  * history log of the {@code PrinterMessageFromOperator} attribute values.
  49  * <p>
  50  * <b>IPP Compatibility:</b> The string value gives the IPP name value. The
  51  * locale gives the IPP natural language. The category name returned by
  52  * {@code getName()} gives the IPP attribute name.
  53  *
  54  * @author Alan Kaminsky
  55  */
  56 public final class PrinterMessageFromOperator   extends TextSyntax
  57     implements PrintServiceAttribute {
  58 
  59     /**
  60      * Use serialVersionUID from JDK 1.4 for interoperability.
  61      */
  62     static final long serialVersionUID = -4486871203218629318L;
  63 
  64     /**
  65      * Constructs a new printer message from operator attribute with the given
  66      * message and locale.
  67      *
  68      * @param  message the message
  69      * @param  locale natural language of the text string. {@code null} is
  70      *         interpreted to mean the default locale as returned by
  71      *         {@code Locale.getDefault()}
  72      * @throws NullPointerException if {@code message} is {@code null}
  73      */
  74     public PrinterMessageFromOperator(String message, Locale locale) {
  75         super (message, locale);
  76     }
  77 
  78     /**
  79      * Returns whether this printer message from operator attribute is
  80      * equivalent to the passed in object. To be equivalent, all of the
  81      * following conditions must be true:
  82      * <ol type=1>
  83      *   <li>{@code object} is not {@code null}.
  84      *   <li>{@code object} is an instance of class
  85      *   {@code PrinterMessageFromOperator}.
  86      *   <li>This printer message from operator attribute's underlying string
  87      *   and {@code object}'s underlying string are equal.
  88      *   <li>This printer message from operator attribute's locale and
  89      *   {@code object}'s locale are equal.
  90      * </ol>
  91      *
  92      * @param  object {@code Object} to compare to
  93      * @return {@code true} if {@code object} is equivalent to this printer
  94      *         message from operator attribute, {@code false} otherwise
  95      */
  96     public boolean equals(Object object) {
  97         return (super.equals(object) &&
  98                 object instanceof PrinterMessageFromOperator);
  99     }
 100 
 101     /**
 102      * Get the printing attribute class which is to be used as the "category"
 103      * for this printing attribute value.
 104      * <p>
 105      * For class {@code PrinterMessageFromOperator}, the category is class
 106      * {@code PrinterMessageFromOperator} itself.
 107      *
 108      * @return printing attribute class (category), an instance of class
 109      *         {@link Class java.lang.Class}
 110      */
 111     public final Class<? extends Attribute> getCategory() {
 112         return PrinterMessageFromOperator.class;
 113     }
 114 
 115     /**
 116      * Get the name of the category of which this attribute value is an
 117      * instance.
 118      * <p>
 119      * For class {@code PrinterMessageFromOperator}, the category name is
 120      * {@code "printer-message-from-operator"}.
 121      *
 122      * @return attribute category name
 123      */
 124     public final String getName() {
 125         return "printer-message-from-operator";
 126     }
 127 }