001 /*
002 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.print.attribute.standard;
026
027 import java.util.Locale;
028
029 import javax.print.attribute.Attribute;
030 import javax.print.attribute.TextSyntax;
031 import javax.print.attribute.DocAttribute;
032
033 /**
034 * Class DocumentName is a printing attribute class, a text attribute, that
035 * specifies the name of a document. DocumentName is an attribute of the print
036 * data (the doc), not of the Print Job. A document's name is an arbitrary
037 * string defined by the client.
038 * However if a JobName is not specified, the DocumentName should be used
039 * instead, which implies that supporting specification of DocumentName
040 * requires reporting of JobName and vice versa.
041 * See {@link JobName JobName} for more information.
042 * <P>
043 * <B>IPP Compatibility:</B> The string value gives the IPP name value. The
044 * locale gives the IPP natural language. The category name returned by
045 * <CODE>getName()</CODE> gives the IPP attribute name.
046 * <P>
047 *
048 * @author Alan Kaminsky
049 */
050 public final class DocumentName extends TextSyntax implements
051 DocAttribute {
052
053 private static final long serialVersionUID = 7883105848533280430L;
054
055 /**
056 * Constructs a new document name attribute with the given document name
057 * and locale.
058 *
059 * @param documentName Document name.
060 * @param locale Natural language of the text string. null
061 * is interpreted to mean the default locale as returned
062 * by <code>Locale.getDefault()</code>
063 *
064 * @exception NullPointerException
065 * (unchecked exception) Thrown if <CODE>documentName</CODE> is null.
066 */
067 public DocumentName(String documentName, Locale locale) {
068 super (documentName, locale);
069 }
070
071 /**
072 * Returns whether this document name attribute is equivalent to the
073 * passed in object.
074 * To be equivalent, all of the following conditions must be true:
075 * <OL TYPE=1>
076 * <LI>
077 * <CODE>object</CODE> is not null.
078 * <LI>
079 * <CODE>object</CODE> is an instance of class DocumentName.
080 * <LI>
081 * This document name attribute's underlying string and
082 * <CODE>object</CODE>'s underlying string are equal.
083 * <LI>
084 * This document name attribute's locale and <CODE>object</CODE>'s locale
085 * are equal.
086 * </OL>
087 *
088 * @param object Object to compare to.
089 *
090 * @return True if <CODE>object</CODE> is equivalent to this document
091 * name attribute, false otherwise.
092 */
093 public boolean equals(Object object) {
094 return (super .equals(object) && object instanceof DocumentName);
095 }
096
097 /**
098 * Get the printing attribute class which is to be used as the "category"
099 * for this printing attribute value.
100 * <P>
101 * For class DocumentName, the category is class DocumentName itself.
102 *
103 * @return Printing attribute class (category), an instance of class
104 * {@link java.lang.Class java.lang.Class}.
105 */
106 public final Class<? extends Attribute> getCategory() {
107 return DocumentName.class;
108 }
109
110 /**
111 * Get the name of the category of which this attribute value is an
112 * instance.
113 * <P>
114 * For class DocumentName, the category name is <CODE>"document-name"</CODE>.
115 *
116 * @return Attribute category name.
117 */
118 public final String getName() {
119 return "document-name";
120 }
121
122 }
|