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