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