jdk/src/java.desktop/share/classes/javax/print/attribute/standard/RequestingUserName.java
changeset 47196 a3211bb4daff
parent 35667 ed476aba94de
equal deleted inserted replaced
47195:b309b58eb190 47196:a3211bb4daff
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
     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.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    20  *
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    23  * questions.
    24  */
    24  */
       
    25 
    25 package javax.print.attribute.standard;
    26 package javax.print.attribute.standard;
    26 
    27 
    27 import java.util.Locale;
    28 import java.util.Locale;
    28 
    29 
    29 import javax.print.attribute.Attribute;
    30 import javax.print.attribute.Attribute;
       
    31 import javax.print.attribute.PrintRequestAttribute;
    30 import javax.print.attribute.TextSyntax;
    32 import javax.print.attribute.TextSyntax;
    31 import javax.print.attribute.PrintRequestAttribute;
       
    32 
    33 
    33 /**
    34 /**
    34  * Class RequestingUserName is a printing attribute class, a text attribute,
    35  * Class {@code RequestingUserName} is a printing attribute class, a text
    35  * that specifies the name of the end user that submitted the print job. A
    36  * attribute, that specifies the name of the end user that submitted the print
    36  * requesting user name is an arbitrary string defined by the client. The
    37  * job. A requesting user name is an arbitrary string defined by the client. The
    37  * printer does not put the client-specified RequestingUserName attribute into
    38  * printer does not put the client-specified {@code RequestingUserName}
    38  * the Print Job's attribute set; rather, the printer puts in a {@link
    39  * attribute into the Print Job's attribute set; rather, the printer puts in a
    39  * JobOriginatingUserName JobOriginatingUserName} attribute.
    40  * {@link JobOriginatingUserName JobOriginatingUserName} attribute. This means
    40  * This means that services which support specifying a username with this
    41  * that services which support specifying a username with this attribute should
    41  * attribute should also report a JobOriginatingUserName in the job's
    42  * also report a {@code JobOriginatingUserName} in the job's attribute set. Note
    42  * attribute set. Note that many print services may have a way to independently
    43  * that many print services may have a way to independently authenticate the
    43  * authenticate the user name, and so may state support for a
    44  * user name, and so may state support for a requesting user name, but in
    44  * requesting user name, but in practice will then report the user name
    45  * practice will then report the user name authenticated by the service rather
    45  * authenticated by the service rather than that specified via this
    46  * than that specified via this attribute.
    46  * attribute.
    47  * <p>
    47  * <P>
    48  * <b>IPP Compatibility:</b> The string value gives the IPP name value. The
    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
    49  * locale gives the IPP natural language. The category name returned by
    50  * {@code getName()} gives the IPP attribute name.
    50  * {@code getName()} gives the IPP attribute name.
    51  *
    51  *
    52  * @author  Alan Kaminsky
    52  * @author Alan Kaminsky
    53  */
    53  */
    54 public final class RequestingUserName   extends TextSyntax
    54 public final class RequestingUserName   extends TextSyntax
    55     implements PrintRequestAttribute {
    55     implements PrintRequestAttribute {
    56 
    56 
       
    57     /**
       
    58      * Use serialVersionUID from JDK 1.4 for interoperability.
       
    59      */
    57     private static final long serialVersionUID = -2683049894310331454L;
    60     private static final long serialVersionUID = -2683049894310331454L;
    58 
    61 
    59     /**
    62     /**
    60      * Constructs a new requesting user name attribute with the given user
    63      * Constructs a new requesting user name attribute with the given user name
    61      * name and locale.
    64      * and locale.
    62      *
    65      *
    63      * @param  userName  User name.
    66      * @param  userName user name
    64      * @param  locale    Natural language of the text string. null
    67      * @param  locale natural language of the text string. {@code null} is
    65      * is interpreted to mean the default locale as returned
    68      *         interpreted to mean the default locale as returned by
    66      * by {@code Locale.getDefault()}
    69      *         {@code Locale.getDefault()}
    67      *
    70      * @throws NullPointerException if {@code userName} is {@code null}
    68      * @exception  NullPointerException
       
    69      *     (unchecked exception) Thrown if {@code userName} is null.
       
    70      */
    71      */
    71     public RequestingUserName(String userName, Locale locale) {
    72     public RequestingUserName(String userName, Locale locale) {
    72         super (userName, locale);
    73         super (userName, locale);
    73     }
    74     }
    74 
    75 
    75     /**
    76     /**
    76      * Returns whether this requesting user name attribute is equivalent to
    77      * Returns whether this requesting user name attribute is equivalent to the
    77      * the passed in object. To be equivalent, all of the following
    78      * passed in object. To be equivalent, all of the following conditions must
    78      * conditions must be true:
    79      * be true:
    79      * <OL TYPE=1>
    80      * <ol type=1>
    80      * <LI>
    81      *   <li>{@code object} is not {@code null}.
    81      * {@code object} is not null.
    82      *   <li>{@code object} is an instance of class {@code RequestingUserName}.
    82      * <LI>
    83      *   <li>This requesting user name attribute's underlying string and
    83      * {@code object} is an instance of class RequestingUserName.
    84      *   {@code object}'s underlying string are equal.
    84      * <LI>
    85      *   <li>This requesting user name attribute's locale and {@code object}'s
    85      * This requesting user name attribute's underlying string and
    86      *   locale are equal.
    86      * {@code object}'s underlying string are equal.
    87      * </ol>
    87      * <LI>
       
    88      * This requesting user name attribute's locale and
       
    89      * {@code object}'s locale are equal.
       
    90      * </OL>
       
    91      *
    88      *
    92      * @param  object  Object to compare to.
    89      * @param  object {@code Object} to compare to
    93      *
    90      * @return {@code true} if {@code object} is equivalent to this requesting
    94      * @return  True if {@code object} is equivalent to this requesting
    91      *         user name attribute, {@code false} otherwise
    95      *          user name attribute, false otherwise.
       
    96      */
    92      */
    97     public boolean equals(Object object) {
    93     public boolean equals(Object object) {
    98         return (super.equals(object) &&
    94         return (super.equals(object) &&
    99                 object instanceof RequestingUserName);
    95                 object instanceof RequestingUserName);
   100     }
    96     }
   101 
    97 
   102     /**
    98     /**
   103      * Get the printing attribute class which is to be used as the "category"
    99      * Get the printing attribute class which is to be used as the "category"
   104      * for this printing attribute value.
   100      * for this printing attribute value.
   105      * <P>
   101      * <p>
   106      * For class RequestingUserName, the
   102      * For class {@code RequestingUserName}, the category is class
   107      * category is class RequestingUserName itself.
   103      * {@code RequestingUserName} itself.
   108      *
   104      *
   109      * @return  Printing attribute class (category), an instance of class
   105      * @return printing attribute class (category), an instance of class
   110      *          {@link java.lang.Class java.lang.Class}.
   106      *         {@link Class java.lang.Class}
   111      */
   107      */
   112     public final Class<? extends Attribute> getCategory() {
   108     public final Class<? extends Attribute> getCategory() {
   113         return RequestingUserName.class;
   109         return RequestingUserName.class;
   114     }
   110     }
   115 
   111 
   116     /**
   112     /**
   117      * Get the name of the category of which this attribute value is an
   113      * Get the name of the category of which this attribute value is an
   118      * instance.
   114      * instance.
   119      * <P>
   115      * <p>
   120      * For class RequestingUserName, the
   116      * For class {@code RequestingUserName}, the category name is
   121      * category name is {@code "requesting-user-name"}.
   117      * {@code "requesting-user-name"}.
   122      *
   118      *
   123      * @return  Attribute category name.
   119      * @return attribute category name
   124      */
   120      */
   125     public final String getName() {
   121     public final String getName() {
   126         return "requesting-user-name";
   122         return "requesting-user-name";
   127     }
   123     }
   128 
       
   129 }
   124 }