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.PrintRequestAttribute;
  32 
  33 /**
  34  * Class RequestingUserName is a printing attribute class, a text attribute,
  35  * that specifies the name of the end user that submitted the print job. A
  36  * requesting user name is an arbitrary string defined by the client. The
  37  * printer does not put the client-specified RequestingUserName attribute into
  38  * the Print Job's attribute set; rather, the printer puts in a {@link
  39  * JobOriginatingUserName JobOriginatingUserName} attribute.
  40  * This means that services which support specifying a username with this
  41  * attribute should also report a JobOriginatingUserName in the job's
  42  * attribute set. Note that many print services may have a way to independently
  43  * authenticate the user name, and so may state support for a
  44  * requesting user name, but in practice will then report the user name
  45  * authenticated by the service rather than that specified via this
  46  * attribute.
  47  * <P>
  48  * <B>IPP Compatibility:</B> The string value gives the IPP name value. The
  49  * locale gives the IPP natural language. The category name returned by
  50  * {@code getName()} gives the IPP attribute name.
  51  *
  52  * @author  Alan Kaminsky
  53  */
  54 public final class RequestingUserName   extends TextSyntax
  55     implements PrintRequestAttribute {
  56 
  57     private static final long serialVersionUID = -2683049894310331454L;
  58 
  59     /**
  60      * Constructs a new requesting user name attribute with the given user
  61      * name and locale.
  62      *
  63      * @param  userName  User name.
  64      * @param  locale    Natural language of the text string. null
  65      * is interpreted to mean the default locale as returned
  66      * by {@code Locale.getDefault()}
  67      *
  68      * @exception  NullPointerException
  69      *     (unchecked exception) Thrown if {@code userName} is null.
  70      */
  71     public RequestingUserName(String userName, Locale locale) {
  72         super (userName, locale);
  73     }
  74 
  75     /**
  76      * Returns whether this requesting user name attribute is equivalent to
  77      * the passed in object. To be equivalent, all of the following
  78      * conditions must be true:
  79      * <OL TYPE=1>
  80      * <LI>
  81      * {@code object} is not null.
  82      * <LI>
  83      * {@code object} is an instance of class RequestingUserName.
  84      * <LI>
  85      * This requesting user name attribute's underlying string and
  86      * {@code object}'s underlying string are equal.
  87      * <LI>
  88      * This requesting user name attribute's locale and
  89      * {@code object}'s locale are equal.
  90      * </OL>
  91      *
  92      * @param  object  Object to compare to.
  93      *
  94      * @return  True if {@code object} is equivalent to this requesting
  95      *          user name attribute, false otherwise.
  96      */
  97     public boolean equals(Object object) {
  98         return (super.equals(object) &&
  99                 object instanceof RequestingUserName);
 100     }
 101 
 102     /**
 103      * Get the printing attribute class which is to be used as the "category"
 104      * for this printing attribute value.
 105      * <P>
 106      * For class RequestingUserName, the
 107      * category is class RequestingUserName itself.
 108      *
 109      * @return  Printing attribute class (category), an instance of class
 110      *          {@link java.lang.Class java.lang.Class}.
 111      */
 112     public final Class<? extends Attribute> getCategory() {
 113         return RequestingUserName.class;
 114     }
 115 
 116     /**
 117      * Get the name of the category of which this attribute value is an
 118      * instance.
 119      * <P>
 120      * For class RequestingUserName, the
 121      * category name is {@code "requesting-user-name"}.
 122      *
 123      * @return  Attribute category name.
 124      */
 125     public final String getName() {
 126         return "requesting-user-name";
 127     }
 128 
 129 }