Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/JobName.java
41171 views
/*1* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.print.attribute.standard;2627import java.io.Serial;28import java.util.Locale;2930import javax.print.attribute.Attribute;31import javax.print.attribute.PrintJobAttribute;32import javax.print.attribute.PrintRequestAttribute;33import javax.print.attribute.TextSyntax;3435/**36* Class {@code JobName} is a printing attribute class, a text attribute, that37* specifies the name of a print job. A job's name is an arbitrary string38* defined by the client. It does not need to be unique between different jobs.39* A Print Job's {@code JobName} attribute is set to the value supplied by the40* client in the Print Request's attribute set. If, however, the client does not41* supply a {@code JobName} attribute in the Print Request, the printer, when it42* creates the Print Job, must generate a {@code JobName}. The printer should43* generate the value of the Print Job's {@code JobName} attribute from the44* first of the following sources that produces a value: (1) the45* {@link DocumentName DocumentName} attribute of the first (or only) doc in the46* job, (2) the {@code URL} of the first (or only) doc in the job, if the doc's47* print data representation object is a {@code URL}, or (3) any other piece of48* Print Job specific and/or document content information.49* <p>50* <b>IPP Compatibility:</b> The string value gives the IPP name value. The51* locale gives the IPP natural language. The category name returned by52* {@code getName()} gives the IPP attribute name.53*54* @author Alan Kaminsky55*/56public final class JobName extends TextSyntax57implements PrintRequestAttribute, PrintJobAttribute {5859/**60* Use serialVersionUID from JDK 1.4 for interoperability.61*/62@Serial63private static final long serialVersionUID = 4660359192078689545L;6465/**66* Constructs a new job name attribute with the given job name and locale.67*68* @param jobName job name69* @param locale natural language of the text string. {@code null} is70* interpreted to mean the default locale as returned by71* {@code Locale.getDefault()}72* @throws NullPointerException if {@code jobName} is {@code null}73*/74public JobName(String jobName, Locale locale) {75super (jobName, locale);76}7778/**79* Returns whether this job name attribute is equivalent to the passed in80* object. To be equivalent, all of the following conditions must be true:81* <ol type=1>82* <li>{@code object} is not {@code null}.83* <li>{@code object} is an instance of class {@code JobName}.84* <li>This job name attribute's underlying string and {@code object}'s85* underlying string are equal.86* <li>This job name attribute's locale and {@code object}'s locale are87* equal.88* </ol>89*90* @param object {@code Object} to compare to91* @return {@code true} if {@code object} is equivalent to this job name92* attribute, {@code false} otherwise93*/94public boolean equals(Object object) {95return (super.equals(object) && object instanceof JobName);96}9798/**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 JobName}, the category is class {@code JobName} itself.103*104* @return printing attribute class (category), an instance of class105* {@link Class java.lang.Class}106*/107public final Class<? extends Attribute> getCategory() {108return JobName.class;109}110111/**112* Get the name of the category of which this attribute value is an113* instance.114* <p>115* For class {@code JobName}, the category name is {@code "job-name"}.116*117* @return attribute category name118*/119public final String getName() {120return "job-name";121}122}123124125