1. /*
  2. * @(#)CopiesSupported.java 1.4 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.SetOfIntegerSyntax;
  9. import javax.print.attribute.SupportedValuesAttribute;
  10. /**
  11. * Class CopiesSupported is a printing attribute class, a set of integers, that
  12. * gives the supported values for a {@link Copies Copies} attribute. It is
  13. * restricted to a single contiguous range of integers; multiple non-overlapping
  14. * ranges are not allowed.
  15. * <P>
  16. * <B>IPP Compatibility:</B> The CopiesSupported attribute's canonical array
  17. * form gives the lower and upper bound for the range of copies to be included
  18. * in an IPP "copies-supported" attribute. See class {@link
  19. * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
  20. * explanation of canonical array form. 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 CopiesSupported extends SetOfIntegerSyntax
  27. implements SupportedValuesAttribute {
  28. /**
  29. * Construct a new copies supported attribute containing a single integer.
  30. * That is, only the one value of Copies is supported.
  31. *
  32. * @param member Set member.
  33. *
  34. * @exception IllegalArgumentException
  35. * (Unchecked exception) Thrown if <CODE>member</CODE> is less than 1.
  36. */
  37. public CopiesSupported(int member) {
  38. super (member);
  39. if (member < 1) {
  40. throw new IllegalArgumentException("Copies value < 1 specified");
  41. }
  42. }
  43. /**
  44. * Construct a new copies supported attribute containing a single range of
  45. * integers. That is, only those values of Copies in the one range are
  46. * supported.
  47. *
  48. * @param lowerBound Lower bound of the range.
  49. * @param upperBound Upper bound of the range.
  50. *
  51. * @exception IllegalArgumentException
  52. * (Unchecked exception) Thrown if a null range is specified or if a
  53. * non-null range is specified with <CODE>lowerBound</CODE> less than
  54. * 1.
  55. */
  56. public CopiesSupported(int lowerBound, int upperBound) {
  57. super(lowerBound, upperBound);
  58. if (lowerBound > upperBound) {
  59. throw new IllegalArgumentException("Null range specified");
  60. } else if (lowerBound < 1) {
  61. throw new IllegalArgumentException("Copies value < 1 specified");
  62. }
  63. }
  64. /**
  65. * Returns whether this copies supported attribute is equivalent to the
  66. * passed in object. To be equivalent, all of the following conditions must
  67. * be true:
  68. * <OL TYPE=1>
  69. * <LI>
  70. * <CODE>object</CODE> is not null.
  71. * <LI>
  72. * <CODE>object</CODE> is an instance of class CopiesSupported.
  73. * <LI>
  74. * This copies supported attribute's members and <CODE>object</CODE>'s
  75. * members are the same.
  76. * </OL>
  77. *
  78. * @param object Object to compare to.
  79. *
  80. * @return True if <CODE>object</CODE> is equivalent to this copies
  81. * supported attribute, false otherwise.
  82. */
  83. public boolean equals(Object object) {
  84. return super.equals (object) && object instanceof CopiesSupported;
  85. }
  86. /**
  87. * Get the printing attribute class which is to be used as the "category"
  88. * for this printing attribute value.
  89. * <P>
  90. * For class CopiesSupported, the category
  91. * is class CopiesSupported itself.
  92. *
  93. * @return Printing attribute class (category), an instance of class
  94. * {@link java.lang.Class java.lang.Class}.
  95. */
  96. public final Class getCategory() {
  97. return CopiesSupported.class;
  98. }
  99. /**
  100. * Get the name of the category of which this attribute value is an
  101. * instance.
  102. * <P>
  103. * For class CopiesSupported, the category
  104. * name is <CODE>"copies-supported"</CODE>.
  105. *
  106. * @return Attribute category name.
  107. */
  108. public final String getName() {
  109. return "copies-supported";
  110. }
  111. }