blob: 68a71a18d3f205c1d0460aee0778ee746028506e [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2004 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25package javax.print.attribute.standard;
26
27import java.util.Locale;
28
29import javax.print.attribute.Attribute;
30import javax.print.attribute.TextSyntax;
31import 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()</CODE> gives the IPP attribute name.
51 * <P>
52 *
53 * @author Alan Kaminsky
54 */
55public final class RequestingUserName extends TextSyntax
56 implements PrintRequestAttribute {
57
58 private static final long serialVersionUID = -2683049894310331454L;
59
60 /**
61 * Constructs a new requesting user name attribute with the given user
62 * name and locale.
63 *
64 * @param userName User name.
65 * @param locale Natural language of the text string. null
66 * is interpreted to mean the default locale as returned
67 * by <code>Locale.getDefault()</code>
68 *
69 * @exception NullPointerException
70 * (unchecked exception) Thrown if <CODE>userName</CODE> is null.
71 */
72 public RequestingUserName(String userName, Locale locale) {
73 super (userName, locale);
74 }
75
76 /**
77 * Returns whether this requesting user name attribute is equivalent to
78 * the passed in object. To be equivalent, all of the following
79 * conditions must be true:
80 * <OL TYPE=1>
81 * <LI>
82 * <CODE>object</CODE> is not null.
83 * <LI>
84 * <CODE>object</CODE> is an instance of class RequestingUserName.
85 * <LI>
86 * This requesting user name attribute's underlying string and
87 * <CODE>object</CODE>'s underlying string are equal.
88 * <LI>
89 * This requesting user name attribute's locale and
90 * <CODE>object</CODE>'s locale are equal.
91 * </OL>
92 *
93 * @param object Object to compare to.
94 *
95 * @return True if <CODE>object</CODE> is equivalent to this requesting
96 * user name attribute, false otherwise.
97 */
98 public boolean equals(Object object) {
99 return (super.equals(object) &&
100 object instanceof RequestingUserName);
101 }
102
103 /**
104 * Get the printing attribute class which is to be used as the "category"
105 * for this printing attribute value.
106 * <P>
107 * For class RequestingUserName, the
108 * category is class RequestingUserName itself.
109 *
110 * @return Printing attribute class (category), an instance of class
111 * {@link java.lang.Class java.lang.Class}.
112 */
113 public final Class<? extends Attribute> getCategory() {
114 return RequestingUserName.class;
115 }
116
117 /**
118 * Get the name of the category of which this attribute value is an
119 * instance.
120 * <P>
121 * For class RequestingUserName, the
122 * category name is <CODE>"requesting-user-name"</CODE>.
123 *
124 * @return Attribute category name.
125 */
126 public final String getName() {
127 return "requesting-user-name";
128 }
129
130}