1. /*
  2. * @(#)Media.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 javax.print.attribute.Attribute;
  9. import javax.print.attribute.DocAttribute;
  10. import javax.print.attribute.EnumSyntax;
  11. import javax.print.attribute.PrintRequestAttribute;
  12. import javax.print.attribute.PrintJobAttribute;
  13. /**
  14. * Class Media is a printing attribute class that specifies the
  15. * medium on which to print.
  16. * <p>
  17. * Media may be specified in different ways.
  18. * <ul>
  19. * <li> it may be specified by paper source - eg paper tray
  20. * <li> it may be specified by a standard size - eg "A4"
  21. * <li> it may be specified by a name - eg "letterhead"
  22. * </ul>
  23. * Each of these corresponds to the IPP "media" attribute.
  24. * The current API does not support describing media by characteristics
  25. * (eg colour, opacity).
  26. * This may be supported in a later revision of the specification.
  27. * <p>
  28. * A Media object is constructed with a value which represents
  29. * one of the ways in which the Media attribute can be specified.
  30. * <p>
  31. * <B>IPP Compatibility:</B> The category name returned by
  32. * <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
  33. * integer value is the IPP enum value. The <code>toString()</code> method
  34. * returns the IPP string representation of the attribute value.
  35. * <P>
  36. *
  37. * @author Phil Race
  38. */
  39. public abstract class Media extends EnumSyntax
  40. implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
  41. /**
  42. * Constructs a new media attribute specified by name.
  43. *
  44. * @param value a value
  45. */
  46. protected Media(int value) {
  47. super (value);
  48. }
  49. /**
  50. * Returns whether this media attribute is equivalent to the passed in
  51. * object. To be equivalent, all of the following conditions must be true:
  52. * <OL TYPE=1>
  53. * <LI>
  54. * <CODE>object</CODE> is not null.
  55. * <LI>
  56. * <CODE>object</CODE> is of the same subclass of Media as this object.
  57. * <LI>
  58. * The values are equal.
  59. * </OL>
  60. *
  61. * @param object Object to compare to.
  62. *
  63. * @return True if <CODE>object</CODE> is equivalent to this media
  64. * attribute, false otherwise.
  65. */
  66. public boolean equals(Object object) {
  67. return(object != null && object instanceof Media &&
  68. object.getClass() == this.getClass() &&
  69. ((Media)object).getValue() == this.getValue());
  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 Media and any vendor-defined subclasses, the category is
  76. * class Media itself.
  77. *
  78. * @return Printing attribute class (category), an instance of class
  79. * {@link java.lang.Class java.lang.Class}.
  80. */
  81. public final Class getCategory() {
  82. return Media.class;
  83. }
  84. /**
  85. * Get the name of the category of which this attribute value is an
  86. * instance.
  87. * <P>
  88. * For class Media and any vendor-defined subclasses, the category name is
  89. * <CODE>"media"</CODE>.
  90. *
  91. * @return Attribute category name.
  92. */
  93. public final String getName() {
  94. return "media";
  95. }
  96. }