1. /*
  2. * @(#)PrinterName.java 1.9 04/05/05
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.print.attribute.standard;
  8. import java.util.Locale;
  9. import javax.print.attribute.Attribute;
  10. import javax.print.attribute.TextSyntax;
  11. import javax.print.attribute.PrintServiceAttribute;
  12. /**
  13. * Class PrinterName is a printing attribute class, a text attribute, that
  14. * specifies the name of a printer. It is a name that is more end-user friendly
  15. * than a URI. An administrator determines a printer's name and sets this
  16. * attribute to that name. This name may be the last part of the printer's URI
  17. * or it may be unrelated. In non-US-English locales, a name may contain
  18. * characters that are not allowed in a URI.
  19. * <P>
  20. * <B>IPP Compatibility:</B> The string value gives the IPP name value. The
  21. * locale gives the IPP natural language. The category name returned by
  22. * <CODE>getName()</CODE> gives the IPP attribute name.
  23. * <P>
  24. *
  25. * @author Alan Kaminsky
  26. */
  27. public final class PrinterName extends TextSyntax
  28. implements PrintServiceAttribute {
  29. private static final long serialVersionUID = 299740639137803127L;
  30. /**
  31. * Constructs a new printer name attribute with the given name and locale.
  32. *
  33. * @param printerName Printer name.
  34. * @param locale Natural language of the text string. null
  35. * is interpreted to mean the default locale as returned
  36. * by <code>Locale.getDefault()</code>
  37. *
  38. * @exception NullPointerException
  39. * (unchecked exception) Thrown if <CODE>printerName</CODE> is null.
  40. */
  41. public PrinterName(String printerName, Locale locale) {
  42. super (printerName, locale);
  43. }
  44. /**
  45. * Returns whether this printer name attribute is equivalent to the passed
  46. * in object. To be equivalent, all of the following conditions must be
  47. * true:
  48. * <OL TYPE=1>
  49. * <LI>
  50. * <CODE>object</CODE> is not null.
  51. * <LI>
  52. * <CODE>object</CODE> is an instance of class PrinterName.
  53. * <LI>
  54. * This printer name attribute's underlying string and
  55. * <CODE>object</CODE>'s underlying string are equal.
  56. * <LI>
  57. * This printer name attribute's locale and <CODE>object</CODE>'s locale
  58. * are equal.
  59. * </OL>
  60. *
  61. * @param object Object to compare to.
  62. *
  63. * @return True if <CODE>object</CODE> is equivalent to this printer
  64. * name attribute, false otherwise.
  65. */
  66. public boolean equals(Object object) {
  67. return (super.equals(object) && object instanceof PrinterName);
  68. }
  69. /**
  70. * Get the printing attribute class which is to be used as the "category"
  71. * for this printing attribute value.
  72. * <P>
  73. * For class PrinterName, the category is
  74. * class PrinterName itself.
  75. *
  76. * @return Printing attribute class (category), an instance of class
  77. * {@link java.lang.Class java.lang.Class}.
  78. */
  79. public final Class<? extends Attribute> getCategory() {
  80. return PrinterName.class;
  81. }
  82. /**
  83. * Get the name of the category of which this attribute value is an
  84. * instance.
  85. * <P>
  86. * For class PrinterName, the category
  87. * name is <CODE>"printer-name"</CODE>.
  88. *
  89. * @return Attribute category name.
  90. */
  91. public final String getName() {
  92. return "printer-name";
  93. }
  94. }