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.PrintServiceAttribute;
032
033 /**
034 * Class PrinterName is a printing attribute class, a text attribute, that
035 * specifies the name of a printer. It is a name that is more end-user friendly
036 * than a URI. An administrator determines a printer's name and sets this
037 * attribute to that name. This name may be the last part of the printer's URI
038 * or it may be unrelated. In non-US-English locales, a name may contain
039 * characters that are not allowed in a URI.
040 * <P>
041 * <B>IPP Compatibility:</B> The string value gives the IPP name value. The
042 * locale gives the IPP natural language. The category name returned by
043 * <CODE>getName()</CODE> gives the IPP attribute name.
044 * <P>
045 *
046 * @author Alan Kaminsky
047 */
048 public final class PrinterName extends TextSyntax implements
049 PrintServiceAttribute {
050
051 private static final long serialVersionUID = 299740639137803127L;
052
053 /**
054 * Constructs a new printer name attribute with the given name and locale.
055 *
056 * @param printerName Printer name.
057 * @param locale Natural language of the text string. null
058 * is interpreted to mean the default locale as returned
059 * by <code>Locale.getDefault()</code>
060 *
061 * @exception NullPointerException
062 * (unchecked exception) Thrown if <CODE>printerName</CODE> is null.
063 */
064 public PrinterName(String printerName, Locale locale) {
065 super (printerName, locale);
066 }
067
068 /**
069 * Returns whether this printer name attribute is equivalent to the passed
070 * in object. To be equivalent, all of the following conditions must be
071 * true:
072 * <OL TYPE=1>
073 * <LI>
074 * <CODE>object</CODE> is not null.
075 * <LI>
076 * <CODE>object</CODE> is an instance of class PrinterName.
077 * <LI>
078 * This printer name attribute's underlying string and
079 * <CODE>object</CODE>'s underlying string are equal.
080 * <LI>
081 * This printer name attribute's locale and <CODE>object</CODE>'s locale
082 * are equal.
083 * </OL>
084 *
085 * @param object Object to compare to.
086 *
087 * @return True if <CODE>object</CODE> is equivalent to this printer
088 * name attribute, false otherwise.
089 */
090 public boolean equals(Object object) {
091 return (super .equals(object) && object instanceof PrinterName);
092 }
093
094 /**
095 * Get the printing attribute class which is to be used as the "category"
096 * for this printing attribute value.
097 * <P>
098 * For class PrinterName, the category is
099 * class PrinterName itself.
100 *
101 * @return Printing attribute class (category), an instance of class
102 * {@link java.lang.Class java.lang.Class}.
103 */
104 public final Class<? extends Attribute> getCategory() {
105 return PrinterName.class;
106 }
107
108 /**
109 * Get the name of the category of which this attribute value is an
110 * instance.
111 * <P>
112 * For class PrinterName, the category
113 * name is <CODE>"printer-name"</CODE>.
114 *
115 * @return Attribute category name.
116 */
117 public final String getName() {
118 return "printer-name";
119 }
120
121 }
|