Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/DocumentName.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.DocAttribute;32import javax.print.attribute.TextSyntax;3334/**35* Class {@code DocumentName} is a printing attribute class, a text attribute,36* that specifies the name of a document. {@code DocumentName} is an attribute37* of the print data (the doc), not of the Print Job. A document's name is an38* arbitrary string defined by the client. However if a JobName is not39* specified, the {@code DocumentName} should be used instead, which implies40* that supporting specification of {@code DocumentName} requires reporting of41* JobName and vice versa. See {@link JobName JobName} for more information.42* <p>43* <b>IPP Compatibility:</b> The string value gives the IPP name value. The44* locale gives the IPP natural language. The category name returned by45* {@code getName()} gives the IPP attribute name.46*47* @author Alan Kaminsky48*/49public final class DocumentName extends TextSyntax implements DocAttribute {5051/**52* Use serialVersionUID from JDK 1.4 for interoperability.53*/54@Serial55private static final long serialVersionUID = 7883105848533280430L;5657/**58* Constructs a new document name attribute with the given document name and59* locale.60*61* @param documentName document name62* @param locale natural language of the text string. {@code null} is63* interpreted to mean the default locale as returned by64* {@code Locale.getDefault()}65* @throws NullPointerException if {@code documentName} is {@code null}66*/67public DocumentName(String documentName, Locale locale) {68super (documentName, locale);69}7071/**72* Returns whether this document name attribute is equivalent to the passed73* in object. To be equivalent, all of the following conditions must be74* true:75* <ol type=1>76* <li>{@code object} is not {@code null}.77* <li>{@code object} is an instance of class {@code DocumentName}.78* <li>This document name attribute's underlying string and79* {@code object}'s underlying string are equal.80* <li>This document name attribute's locale and {@code object}'s locale81* are equal.82* </ol>83*84* @param object {@code Object} to compare to85* @return {@code true} if {@code object} is equivalent to this document86* name attribute, {@code false} otherwise87*/88public boolean equals(Object object) {89return (super.equals (object) && object instanceof DocumentName);90}9192/**93* Get the printing attribute class which is to be used as the "category"94* for this printing attribute value.95* <p>96* For class {@code DocumentName}, the category is class97* {@code DocumentName} itself.98*99* @return printing attribute class (category), an instance of class100* {@link Class java.lang.Class}101*/102public final Class<? extends Attribute> getCategory() {103return DocumentName.class;104}105106/**107* Get the name of the category of which this attribute value is an108* instance.109* <p>110* For class {@code DocumentName}, the category name is111* {@code "document-name"}.112*113* @return attribute category name114*/115public final String getName() {116return "document-name";117}118}119120121