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