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.PrintServiceAttribute; 32 33 /** 34 * Class PrinterName is a printing attribute class, a text attribute, that 35 * specifies the name of a printer. It is a name that is more end-user friendly 36 * than a URI. An administrator determines a printer's name and sets this 37 * attribute to that name. This name may be the last part of the printer's URI 38 * or it may be unrelated. In non-US-English locales, a name may contain 39 * characters that are not allowed in a URI. 40 * <P> 41 * <B>IPP Compatibility:</B> The string value gives the IPP name value. The 42 * locale gives the IPP natural language. The category name returned by 43 * <CODE>getName()</CODE> gives the IPP attribute name. 44 * 45 * @author Alan Kaminsky 46 */ 47 public final class PrinterName extends TextSyntax 48 implements PrintServiceAttribute { 49 50 private static final long serialVersionUID = 299740639137803127L; 51 52 /** 53 * Constructs a new printer name attribute with the given name and locale. 54 * 55 * @param printerName Printer name. 56 * @param locale Natural language of the text string. null 57 * is interpreted to mean the default locale as returned 58 * by <code>Locale.getDefault()</code> 59 * 60 * @exception NullPointerException 61 * (unchecked exception) Thrown if <CODE>printerName</CODE> is null. 62 */ 63 public PrinterName(String printerName, Locale locale) { 64 super (printerName, locale); 65 } 66 67 /** 68 * Returns whether this printer name attribute is equivalent to the passed 69 * in object. To be equivalent, all of the following conditions must be 70 * true: 71 * <OL TYPE=1> 72 * <LI> 73 * <CODE>object</CODE> is not null. 74 * <LI> 75 * <CODE>object</CODE> is an instance of class PrinterName. 76 * <LI> 77 * This printer name attribute's underlying string and 78 * <CODE>object</CODE>'s underlying string are equal. 79 * <LI> 80 * This printer name attribute's locale and <CODE>object</CODE>'s locale 81 * are equal. 82 * </OL> 83 * 84 * @param object Object to compare to. 85 * 86 * @return True if <CODE>object</CODE> is equivalent to this printer 87 * name attribute, false otherwise. 88 */ 89 public boolean equals(Object object) { 90 return (super.equals(object) && object instanceof PrinterName); 91 } 92 93 /** 94 * Get the printing attribute class which is to be used as the "category" 95 * for this printing attribute value. 96 * <P> 97 * For class PrinterName, the category is 98 * class PrinterName itself. 99 * 100 * @return Printing attribute class (category), an instance of class 101 * {@link java.lang.Class java.lang.Class}. 102 */ 103 public final Class<? extends Attribute> getCategory() { 104 return PrinterName.class; 105 } 106 107 /** 108 * Get the name of the category of which this attribute value is an 109 * instance. 110 * <P> 111 * For class PrinterName, the category 112 * name is <CODE>"printer-name"</CODE>. 113 * 114 * @return Attribute category name. 115 */ 116 public final String getName() { 117 return "printer-name"; 118 } 119 120 } | 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.PrintServiceAttribute; 32 33 /** 34 * Class PrinterName is a printing attribute class, a text attribute, that 35 * specifies the name of a printer. It is a name that is more end-user friendly 36 * than a URI. An administrator determines a printer's name and sets this 37 * attribute to that name. This name may be the last part of the printer's URI 38 * or it may be unrelated. In non-US-English locales, a name may contain 39 * characters that are not allowed in a URI. 40 * <P> 41 * <B>IPP Compatibility:</B> The string value gives the IPP name value. The 42 * locale gives the IPP natural language. The category name returned by 43 * {@code getName()} gives the IPP attribute name. 44 * 45 * @author Alan Kaminsky 46 */ 47 public final class PrinterName extends TextSyntax 48 implements PrintServiceAttribute { 49 50 private static final long serialVersionUID = 299740639137803127L; 51 52 /** 53 * Constructs a new printer name attribute with the given name and locale. 54 * 55 * @param printerName Printer name. 56 * @param locale Natural language of the text string. null 57 * is interpreted to mean the default locale as returned 58 * by {@code Locale.getDefault()} 59 * 60 * @exception NullPointerException 61 * (unchecked exception) Thrown if {@code printerName} is null. 62 */ 63 public PrinterName(String printerName, Locale locale) { 64 super (printerName, locale); 65 } 66 67 /** 68 * Returns whether this printer name attribute is equivalent to the passed 69 * in object. To be equivalent, all of the following conditions must be 70 * true: 71 * <OL TYPE=1> 72 * <LI> 73 * {@code object} is not null. 74 * <LI> 75 * {@code object} is an instance of class PrinterName. 76 * <LI> 77 * This printer name attribute's underlying string and 78 * {@code object}'s underlying string are equal. 79 * <LI> 80 * This printer name attribute's locale and {@code object}'s locale 81 * are equal. 82 * </OL> 83 * 84 * @param object Object to compare to. 85 * 86 * @return True if {@code object} is equivalent to this printer 87 * name attribute, false otherwise. 88 */ 89 public boolean equals(Object object) { 90 return (super.equals(object) && object instanceof PrinterName); 91 } 92 93 /** 94 * Get the printing attribute class which is to be used as the "category" 95 * for this printing attribute value. 96 * <P> 97 * For class PrinterName, the category is 98 * class PrinterName itself. 99 * 100 * @return Printing attribute class (category), an instance of class 101 * {@link java.lang.Class java.lang.Class}. 102 */ 103 public final Class<? extends Attribute> getCategory() { 104 return PrinterName.class; 105 } 106 107 /** 108 * Get the name of the category of which this attribute value is an 109 * instance. 110 * <P> 111 * For class PrinterName, the category 112 * name is {@code "printer-name"}. 113 * 114 * @return Attribute category name. 115 */ 116 public final String getName() { 117 return "printer-name"; 118 } 119 120 } |