1. /*
  2. * @(#)PrinterInfo.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 PrinterInfo is a printing attribute class, a text attribute, that
  14. * provides descriptive information about a printer. This could include things
  15. * like: <CODE>"This printer can be used for printing color transparencies for
  16. * HR presentations"</CODE>, or <CODE>"Out of courtesy for others, please
  17. * print only small (1-5 page) jobs at this printer"</CODE>, or even \
  18. * <CODE>"This printer is going away on July 1, 1997, please find a new
  19. * printer"</CODE>.
  20. * <P>
  21. * <B>IPP Compatibility:</B> The string value gives the IPP name value. The
  22. * locale gives the IPP natural language. The category name returned by
  23. * <CODE>getName()</CODE> gives the IPP attribute name.
  24. * <P>
  25. *
  26. * @author Alan Kaminsky
  27. */
  28. public final class PrinterInfo extends TextSyntax
  29. implements PrintServiceAttribute {
  30. private static final long serialVersionUID = 7765280618777599727L;
  31. /**
  32. * Constructs a new printer info attribute with the given information
  33. * string and locale.
  34. *
  35. * @param info Printer information string.
  36. * @param locale Natural language of the text string. null
  37. * is interpreted to mean the default locale as returned
  38. * by <code>Locale.getDefault()</code>
  39. *
  40. * @exception NullPointerException
  41. * (unchecked exception) Thrown if <CODE>info</CODE> is null.
  42. */
  43. public PrinterInfo(String info, Locale locale) {
  44. super (info, locale);
  45. }
  46. /**
  47. * Returns whether this printer info attribute is equivalent to the passed
  48. * in object. To be equivalent, all of the following conditions must be
  49. * true:
  50. * <OL TYPE=1>
  51. * <LI>
  52. * <CODE>object</CODE> is not null.
  53. * <LI>
  54. * <CODE>object</CODE> is an instance of class PrinterInfo.
  55. * <LI>
  56. * This printer info attribute's underlying string and
  57. * <CODE>object</CODE>'s underlying string are equal.
  58. * <LI>
  59. * This printer info attribute's locale and <CODE>object</CODE>'s
  60. * locale are equal.
  61. * </OL>
  62. *
  63. * @param object Object to compare to.
  64. *
  65. * @return True if <CODE>object</CODE> is equivalent to this printer
  66. * info attribute, false otherwise.
  67. */
  68. public boolean equals(Object object) {
  69. return (super.equals(object) && object instanceof PrinterInfo);
  70. }
  71. /**
  72. * Get the printing attribute class which is to be used as the "category"
  73. * for this printing attribute value.
  74. * <P>
  75. * For class PrinterInfo, the category is class PrinterInfo itself.
  76. *
  77. * @return Printing attribute class (category), an instance of class
  78. * {@link java.lang.Class java.lang.Class}.
  79. */
  80. public final Class<? extends Attribute> getCategory() {
  81. return PrinterInfo.class;
  82. }
  83. /**
  84. * Get the name of the category of which this attribute value is an
  85. * instance.
  86. * <P>
  87. * For class PrinterInfo, the category name is <CODE>"printer-info"</CODE>.
  88. *
  89. * @return Attribute category name.
  90. */
  91. public final String getName() {
  92. return "printer-info";
  93. }
  94. }