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 } | 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 26 package javax.print.attribute.standard; 27 28 import java.util.Locale; 29 30 import javax.print.attribute.Attribute; 31 import javax.print.attribute.PrintRequestAttribute; 32 import javax.print.attribute.TextSyntax; 33 34 /** 35 * Class {@code RequestingUserName} is a printing attribute class, a text 36 * attribute, that specifies the name of the end user that submitted the print 37 * job. A requesting user name is an arbitrary string defined by the client. The 38 * printer does not put the client-specified {@code RequestingUserName} 39 * attribute into the Print Job's attribute set; rather, the printer puts in a 40 * {@link JobOriginatingUserName JobOriginatingUserName} attribute. This means 41 * that services which support specifying a username with this attribute should 42 * also report a {@code JobOriginatingUserName} in the job's attribute set. Note 43 * that many print services may have a way to independently authenticate the 44 * user name, and so may state support for a requesting user name, but in 45 * practice will then report the user name authenticated by the service rather 46 * than that specified via this 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 /** 58 * Use serialVersionUID from JDK 1.4 for interoperability. 59 */ 60 private static final long serialVersionUID = -2683049894310331454L; 61 62 /** 63 * Constructs a new requesting user name attribute with the given user name 64 * and locale. 65 * 66 * @param userName user name 67 * @param locale natural language of the text string. {@code null} is 68 * interpreted to mean the default locale as returned by 69 * {@code Locale.getDefault()} 70 * @throws NullPointerException if {@code userName} is {@code 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 the 78 * passed in object. To be equivalent, all of the following conditions must 79 * be true: 80 * <ol type=1> 81 * <li>{@code object} is not {@code null}. 82 * <li>{@code object} is an instance of class {@code RequestingUserName}. 83 * <li>This requesting user name attribute's underlying string and 84 * {@code object}'s underlying string are equal. 85 * <li>This requesting user name attribute's locale and {@code object}'s 86 * locale are equal. 87 * </ol> 88 * 89 * @param object {@code Object} to compare to 90 * @return {@code true} if {@code object} is equivalent to this requesting 91 * user name attribute, {@code false} otherwise 92 */ 93 public boolean equals(Object object) { 94 return (super.equals(object) && 95 object instanceof RequestingUserName); 96 } 97 98 /** 99 * Get the printing attribute class which is to be used as the "category" 100 * for this printing attribute value. 101 * <p> 102 * For class {@code RequestingUserName}, the category is class 103 * {@code RequestingUserName} itself. 104 * 105 * @return printing attribute class (category), an instance of class 106 * {@link Class java.lang.Class} 107 */ 108 public final Class<? extends Attribute> getCategory() { 109 return RequestingUserName.class; 110 } 111 112 /** 113 * Get the name of the category of which this attribute value is an 114 * instance. 115 * <p> 116 * For class {@code RequestingUserName}, the category name is 117 * {@code "requesting-user-name"}. 118 * 119 * @return attribute category name 120 */ 121 public final String getName() { 122 return "requesting-user-name"; 123 } 124 } |