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 26package javax.print.attribute.standard; 27 28import java.util.Locale; 29 30import javax.print.attribute.Attribute; 31import javax.print.attribute.PrintJobAttribute; 32import javax.print.attribute.TextSyntax; 33 34/** 35 * Class {@code JobOriginatingUserName} is a printing attribute class, a text 36 * attribute, that contains the name of the end user that submitted the print 37 * job. If possible, the printer sets this attribute to the most authenticated 38 * printable user name that it can obtain from the authentication service that 39 * authenticated the submitted Print Request. If such is not available, the 40 * printer uses the value of the {@link RequestingUserName RequestingUserName} 41 * attribute supplied by the client in the Print Request's attribute set. If no 42 * authentication service is available, and the client did not supply a 43 * {@link RequestingUserName RequestingUserName} attribute, the printer sets the 44 * JobOriginatingUserName attribute to an empty (zero-length) string. 45 * <p> 46 * <b>IPP Compatibility:</b> The string value gives the IPP name value. The 47 * locale gives the IPP natural language. The category name returned by 48 * {@code getName()} gives the IPP attribute name. 49 * 50 * @author Alan Kaminsky 51 */ 52public final class JobOriginatingUserName extends TextSyntax 53 implements PrintJobAttribute { 54 55 /** 56 * Use serialVersionUID from JDK 1.4 for interoperability. 57 */ 58 private static final long serialVersionUID = -8052537926362933477L; 59 60 /** 61 * Constructs a new job originating 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. {@code null} is 66 * interpreted to mean the default locale as returned by 67 * {@code Locale.getDefault()} 68 * @throws NullPointerException if {@code userName} is {@code 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>{@code object} is not {@code null}. 80 * <li>{@code object} is an instance of class 81 * {@code JobOriginatingUserName}. 82 * <li>This job originating user name attribute's underlying string and 83 * {@code object}'s underlying string are equal. 84 * <li>This job originating user name attribute's locale and 85 * {@code object}'s locale are equal. 86 * </ol> 87 * 88 * @param object {@code Object} to compare to 89 * @return {@code true} if {@code object} is equivalent to this job 90 * originating user name attribute, {@code false} otherwise 91 */ 92 public boolean equals(Object object) { 93 return (super.equals (object) && 94 object instanceof JobOriginatingUserName); 95 } 96 97 /** 98 * Get the printing attribute class which is to be used as the "category" 99 * for this printing attribute value. 100 * <p> 101 * For class {@code JobOriginatingUserName}, the category is class 102 * {@code JobOriginatingUserName} itself. 103 * 104 * @return printing attribute class (category), an instance of class 105 * {@link Class java.lang.Class} 106 */ 107 public final Class<? extends Attribute> getCategory() { 108 return JobOriginatingUserName.class; 109 } 110 111 /** 112 * Get the name of the category of which this attribute value is an 113 * instance. 114 * <p> 115 * For class {@code JobOriginatingUserName}, the category name is 116 * {@code "job-originating-user-name"}. 117 * 118 * @return attribute category name 119 */ 120 public final String getName() { 121 return "job-originating-user-name"; 122 } 123} 124