1. /*
  2. * @(#)NumberOfDocuments.java 1.7 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.IntegerSyntax;
  10. import javax.print.attribute.PrintJobAttribute;
  11. /**
  12. * Class NumberOfDocuments is an integer valued printing attribute that
  13. * indicates the number of individual docs the printer has accepted for this
  14. * job, regardless of whether the docs' print data has reached the printer or
  15. * not.
  16. * <P>
  17. * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
  18. * category name returned by <CODE>getName()</CODE> gives the IPP attribute
  19. * name.
  20. * <P>
  21. *
  22. * @author Alan Kaminsky
  23. */
  24. public final class NumberOfDocuments extends IntegerSyntax
  25. implements PrintJobAttribute {
  26. private static final long serialVersionUID = 7891881310684461097L;
  27. /**
  28. * Construct a new number of documents attribute with the given integer
  29. * value.
  30. *
  31. * @param value Integer value.
  32. *
  33. * @exception IllegalArgumentException
  34. * (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
  35. */
  36. public NumberOfDocuments(int value) {
  37. super (value, 0, Integer.MAX_VALUE);
  38. }
  39. /**
  40. * Returns whether this number of documents attribute is equivalent to the
  41. * passed in object. To be equivalent, all of the following conditions
  42. * must be true:
  43. * <OL TYPE=1>
  44. * <LI>
  45. * <CODE>object</CODE> is not null.
  46. * <LI>
  47. * <CODE>object</CODE> is an instance of class NumberOfDocuments.
  48. * <LI>
  49. * This number of documents attribute's value and <CODE>object</CODE>'s
  50. * value are equal.
  51. * </OL>
  52. *
  53. * @param object Object to compare to.
  54. *
  55. * @return True if <CODE>object</CODE> is equivalent to this number of
  56. * documents attribute, false otherwise.
  57. */
  58. public boolean equals(Object object) {
  59. return (super.equals (object) &&
  60. object instanceof NumberOfDocuments);
  61. }
  62. /**
  63. * Get the printing attribute class which is to be used as the "category"
  64. * for this printing attribute value.
  65. * <P>
  66. * For class NumberOfDocuments, the
  67. * category is class NumberOfDocuments itself.
  68. *
  69. * @return Printing attribute class (category), an instance of class
  70. * {@link java.lang.Class java.lang.Class}.
  71. */
  72. public final Class<? extends Attribute> getCategory() {
  73. return NumberOfDocuments.class;
  74. }
  75. /**
  76. * Get the name of the category of which this attribute value is an
  77. * instance.
  78. * <P>
  79. * For class NumberOfDocuments, the
  80. * category name is <CODE>"number-of-documents"</CODE>.
  81. *
  82. * @return Attribute category name.
  83. */
  84. public final String getName() {
  85. return "number-of-documents";
  86. }
  87. }