1. /*
  2. * @(#)Media.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 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. private static final long serialVersionUID = -2823970704630722439L;
  42. /**
  43. * Constructs a new media attribute specified by name.
  44. *
  45. * @param value a value
  46. */
  47. protected Media(int value) {
  48. super (value);
  49. }
  50. /**
  51. * Returns whether this media attribute is equivalent to the passed in
  52. * object. To be equivalent, all of the following conditions must be true:
  53. * <OL TYPE=1>
  54. * <LI>
  55. * <CODE>object</CODE> is not null.
  56. * <LI>
  57. * <CODE>object</CODE> is of the same subclass of Media as this object.
  58. * <LI>
  59. * The values are equal.
  60. * </OL>
  61. *
  62. * @param object Object to compare to.
  63. *
  64. * @return True if <CODE>object</CODE> is equivalent to this media
  65. * attribute, false otherwise.
  66. */
  67. public boolean equals(Object object) {
  68. return(object != null && object instanceof Media &&
  69. object.getClass() == this.getClass() &&
  70. ((Media)object).getValue() == this.getValue());
  71. }
  72. /**
  73. * Get the printing attribute class which is to be used as the "category"
  74. * for this printing attribute value.
  75. * <P>
  76. * For class Media and any vendor-defined subclasses, the category is
  77. * class Media itself.
  78. *
  79. * @return Printing attribute class (category), an instance of class
  80. * {@link java.lang.Class java.lang.Class}.
  81. */
  82. public final Class<? extends Attribute> getCategory() {
  83. return Media.class;
  84. }
  85. /**
  86. * Get the name of the category of which this attribute value is an
  87. * instance.
  88. * <P>
  89. * For class Media and any vendor-defined subclasses, the category name is
  90. * <CODE>"media"</CODE>.
  91. *
  92. * @return Attribute category name.
  93. */
  94. public final String getName() {
  95. return "media";
  96. }
  97. }