1. /*
  2. * @(#)JobHoldUntil.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 java.util.Date;
  9. import javax.print.attribute.DateTimeSyntax;
  10. import javax.print.attribute.PrintRequestAttribute;
  11. import javax.print.attribute.PrintJobAttribute;
  12. /**
  13. * Class JobHoldUntil is a printing attribute class, a date-time attribute, that
  14. * specifies the exact date and time at which the job must become a candidate
  15. * for printing.
  16. * <P>
  17. * If the value of this attribute specifies a date-time that is in the future,
  18. * the printer should add the {@link JobStateReason JobStateReason} value of
  19. * JOB_HOLD_UNTIL_SPECIFIED to the job's {@link JobStateReasons JobStateReasons}
  20. * attribute, must move the job to the PENDING_HELD state, and must not schedule
  21. * the job for printing until the specified date-time arrives.
  22. * <P>
  23. * When the specified date-time arrives, the printer must remove the {@link
  24. * JobStateReason JobStateReason} value of JOB_HOLD_UNTIL_SPECIFIED from the
  25. * job's {@link JobStateReasons JobStateReasons} attribute, if present. If there
  26. * are no other job state reasons that keep the job in the PENDING_HELD state,
  27. * the printer must consider the job as a candidate for processing by moving the
  28. * job to the PENDING state.
  29. * <P>
  30. * If the specified date-time has already passed, the job must be a candidate
  31. * for processing immediately. Thus, one way to make the job immediately become
  32. * a candidate for processing is to specify a JobHoldUntil attribute constructed
  33. * like this (denoting a date-time of January 1, 1970, 00:00:00 GMT):
  34. * <PRE>
  35. * JobHoldUntil immediately = new JobHoldUntil (new Date (0L));
  36. * </PRE>
  37. * <P>
  38. * If the client does not supply this attribute in a Print Request and the
  39. * printer supports this attribute, the printer must use its
  40. * (implementation-dependent) default JobHoldUntil value at job submission time
  41. * (unlike most job template attributes that are used if necessary at job
  42. * processing time).
  43. * <P>
  44. * To construct a JobHoldUntil attribute from separate values of the year,
  45. * month, day, hour, minute, and so on, use a {@link java.util.Calendar
  46. * Calendar} object to construct a {@link java.util.Date Date} object, then use
  47. * the {@link java.util.Date Date} object to construct the JobHoldUntil
  48. * attribute. To convert a JobHoldUntil attribute to separate values of the
  49. * year, month, day, hour, minute, and so on, create a {@link java.util.Calendar
  50. * Calendar} object and set it to the {@link java.util.Date Date} from the
  51. * JobHoldUntil attribute.
  52. * <P>
  53. * <B>IPP Compatibility:</B> Although IPP supports a "job-hold-until" attribute
  54. * specified as a keyword, IPP does not at this time support a "job-hold-until"
  55. * attribute specified as a date and time. However, the date and time can be
  56. * converted to one of the standard IPP keywords with some loss of precision;
  57. * for example, a JobHoldUntil value with today's date and 9:00pm local time
  58. * might be converted to the standard IPP keyword "night". The category name
  59. * returned by <CODE>getName()</CODE> gives the IPP attribute name.
  60. * <P>
  61. *
  62. * @author Alan Kaminsky
  63. */
  64. public final class JobHoldUntil extends DateTimeSyntax
  65. implements PrintRequestAttribute, PrintJobAttribute {
  66. /**
  67. * Construct a new job hold until date-time attribute with the given
  68. * {@link java.util.Date Date} value.
  69. *
  70. * @param dateTime {@link java.util.Date Date} value.
  71. *
  72. * @exception NullPointerException
  73. * (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.
  74. */
  75. public JobHoldUntil(Date dateTime) {
  76. super (dateTime);
  77. }
  78. /**
  79. * Returns whether this job hold until attribute is equivalent to the
  80. * passed in object. To be equivalent, all of the following conditions
  81. * must be true:
  82. * <OL TYPE=1>
  83. * <LI>
  84. * <CODE>object</CODE> is not null.
  85. * <LI>
  86. * <CODE>object</CODE> is an instance of class JobHoldUntil.
  87. * <LI>
  88. * This job hold until attribute's {@link java.util.Date Date} value and
  89. * <CODE>object</CODE>'s {@link java.util.Date Date} value are equal.
  90. * </OL>
  91. *
  92. * @param object Object to compare to.
  93. *
  94. * @return True if <CODE>object</CODE> is equivalent to this job hold
  95. * until attribute, false otherwise.
  96. */
  97. public boolean equals(Object object) {
  98. return (super.equals(object) && object instanceof JobHoldUntil);
  99. }
  100. /**
  101. * Get the printing attribute class which is to be used as the "category"
  102. * for this printing attribute value.
  103. * <P>
  104. * For class JobHoldUntil, the category is class JobHoldUntil itself.
  105. *
  106. * @return Printing attribute class (category), an instance of class
  107. * {@link java.lang.Class java.lang.Class}.
  108. */
  109. public final Class getCategory() {
  110. return JobHoldUntil.class;
  111. }
  112. /**
  113. * Get the name of the category of which this attribute value is an
  114. * instance.
  115. * <P>
  116. * For class JobHoldUntil, the category name is <CODE>"job-hold-until"</CODE>.
  117. *
  118. * @return Attribute category name.
  119. */
  120. public final String getName() {
  121. return "job-hold-until";
  122. }
  123. }