1 /*
   2  * Copyright (c) 2000, 2004, 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.PrintJobAttribute;
  32 
  33 /**
  34  * Class JobOriginatingUserName is a printing attribute class, a text
  35  * attribute, that contains the name of the end user that submitted the
  36  * print job. If possible, the printer sets this attribute to the most
  37  * authenticated printable user name that it can obtain from the
  38  * authentication service that authenticated the submitted Print Request.
  39  * If such is not available, the printer uses the value of the
  40  * {@link RequestingUserName RequestingUserName}
  41  * attribute supplied by the client in the Print Request's attribute set.
  42  * If no authentication service is available, and the client did not supply
  43  * a {@link RequestingUserName RequestingUserName} attribute,
  44  * the printer sets the JobOriginatingUserName attribute to an empty
  45  * (zero-length) string.
  46  * <P>
  47  * <B>IPP Compatibility:</B> The string value gives the IPP name value. The
  48  * locale gives the IPP natural language. The category name returned by
  49  * <CODE>getName()</CODE> gives the IPP attribute name.
  50  *
  51  * @author  Alan Kaminsky
  52  */
  53 public final class JobOriginatingUserName extends TextSyntax
  54         implements PrintJobAttribute {
  55 
  56     private static final long serialVersionUID = -8052537926362933477L;
  57 
  58     /**
  59      * Constructs a new job originating user name attribute with the given
  60      * user name and locale.
  61      *
  62      * @param  userName  User name.
  63      * @param  locale    Natural language of the text string. null
  64      * is interpreted to mean the default locale as returned
  65      * by <code>Locale.getDefault()</code>
  66      *
  67      * @exception  NullPointerException
  68      *     (unchecked exception) Thrown if <CODE>userName</CODE> is null.
  69      */
  70     public JobOriginatingUserName(String userName, Locale locale) {
  71         super (userName, locale);
  72     }
  73 
  74     /**
  75      * Returns whether this job originating user name attribute is equivalent to
  76      * the passed in object. To be equivalent, all of the following conditions
  77      * must be true:
  78      * <OL TYPE=1>
  79      * <LI>
  80      * <CODE>object</CODE> is not null.
  81      * <LI>
  82      * <CODE>object</CODE> is an instance of class JobOriginatingUserName.
  83      * <LI>
  84      * This job originating user name attribute's underlying string and
  85      * <CODE>object</CODE>'s underlying string are equal.
  86      * <LI>
  87      * This job originating user name attribute's locale and
  88      * <CODE>object</CODE>'s locale are equal.
  89      * </OL>
  90      *
  91      * @param  object  Object to compare to.
  92      *
  93      * @return  True if <CODE>object</CODE> is equivalent to this job
  94      *          originating user name attribute, false otherwise.
  95      */
  96     public boolean equals(Object object) {
  97         return (super.equals (object) &&
  98                 object instanceof JobOriginatingUserName);
  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 JobOriginatingUserName, the
 106      * category is class JobOriginatingUserName itself.
 107      *
 108      * @return  Printing attribute class (category), an instance of class
 109      *          {@link java.lang.Class java.lang.Class}.
 110      */
 111     public final Class<? extends Attribute> getCategory() {
 112         return JobOriginatingUserName.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 JobOriginatingUserName, the
 120      * category name is <CODE>"job-originating-user-name"</CODE>.
 121      *
 122      * @return  Attribute category name.
 123      */
 124     public final String getName() {
 125         return "job-originating-user-name";
 126     }
 127 
 128 }