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