blob: d5846fcb2221e092362cdae117a2f0bf3b736feb [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25package javax.print.attribute.standard;
26
27import java.util.Date;
28import javax.print.attribute.Attribute;
29import javax.print.attribute.DateTimeSyntax;
30import javax.print.attribute.PrintRequestAttribute;
31import javax.print.attribute.PrintJobAttribute;
32
33/**
34 * Class JobHoldUntil is a printing attribute class, a date-time attribute, that
35 * specifies the exact date and time at which the job must become a candidate
36 * for printing.
37 * <P>
38 * If the value of this attribute specifies a date-time that is in the future,
39 * the printer should add the {@link JobStateReason JobStateReason} value of
40 * JOB_HOLD_UNTIL_SPECIFIED to the job's {@link JobStateReasons JobStateReasons}
41 * attribute, must move the job to the PENDING_HELD state, and must not schedule
42 * the job for printing until the specified date-time arrives.
43 * <P>
44 * When the specified date-time arrives, the printer must remove the {@link
45 * JobStateReason JobStateReason} value of JOB_HOLD_UNTIL_SPECIFIED from the
46 * job's {@link JobStateReasons JobStateReasons} attribute, if present. If there
47 * are no other job state reasons that keep the job in the PENDING_HELD state,
48 * the printer must consider the job as a candidate for processing by moving the
49 * job to the PENDING state.
50 * <P>
51 * If the specified date-time has already passed, the job must be a candidate
52 * for processing immediately. Thus, one way to make the job immediately become
53 * a candidate for processing is to specify a JobHoldUntil attribute constructed
54 * like this (denoting a date-time of January 1, 1970, 00:00:00 GMT):
55 * <PRE>
56 * JobHoldUntil immediately = new JobHoldUntil (new Date (0L));
57 * </PRE>
58 * <P>
59 * If the client does not supply this attribute in a Print Request and the
60 * printer supports this attribute, the printer must use its
61 * (implementation-dependent) default JobHoldUntil value at job submission time
62 * (unlike most job template attributes that are used if necessary at job
63 * processing time).
64 * <P>
65 * To construct a JobHoldUntil attribute from separate values of the year,
66 * month, day, hour, minute, and so on, use a {@link java.util.Calendar
67 * Calendar} object to construct a {@link java.util.Date Date} object, then use
68 * the {@link java.util.Date Date} object to construct the JobHoldUntil
69 * attribute. To convert a JobHoldUntil attribute to separate values of the
70 * year, month, day, hour, minute, and so on, create a {@link java.util.Calendar
71 * Calendar} object and set it to the {@link java.util.Date Date} from the
72 * JobHoldUntil attribute.
73 * <P>
74 * <B>IPP Compatibility:</B> Although IPP supports a "job-hold-until" attribute
75 * specified as a keyword, IPP does not at this time support a "job-hold-until"
76 * attribute specified as a date and time. However, the date and time can be
77 * converted to one of the standard IPP keywords with some loss of precision;
78 * for example, a JobHoldUntil value with today's date and 9:00pm local time
79 * might be converted to the standard IPP keyword "night". The category name
80 * returned by <CODE>getName()</CODE> gives the IPP attribute name.
81 * <P>
82 *
83 * @author Alan Kaminsky
84 */
85public final class JobHoldUntil extends DateTimeSyntax
86 implements PrintRequestAttribute, PrintJobAttribute {
87
88 private static final long serialVersionUID = -1664471048860415024L;
89
90
91 /**
92 * Construct a new job hold until date-time attribute with the given
93 * {@link java.util.Date Date} value.
94 *
95 * @param dateTime {@link java.util.Date Date} value.
96 *
97 * @exception NullPointerException
98 * (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.
99 */
100 public JobHoldUntil(Date dateTime) {
101 super (dateTime);
102 }
103
104 /**
105 * Returns whether this job hold until attribute is equivalent to the
106 * passed in object. To be equivalent, all of the following conditions
107 * must be true:
108 * <OL TYPE=1>
109 * <LI>
110 * <CODE>object</CODE> is not null.
111 * <LI>
112 * <CODE>object</CODE> is an instance of class JobHoldUntil.
113 * <LI>
114 * This job hold until attribute's {@link java.util.Date Date} value and
115 * <CODE>object</CODE>'s {@link java.util.Date Date} value are equal.
116 * </OL>
117 *
118 * @param object Object to compare to.
119 *
120 * @return True if <CODE>object</CODE> is equivalent to this job hold
121 * until attribute, false otherwise.
122 */
123 public boolean equals(Object object) {
124 return (super.equals(object) && object instanceof JobHoldUntil);
125 }
126
127
128 /**
129 * Get the printing attribute class which is to be used as the "category"
130 * for this printing attribute value.
131 * <P>
132 * For class JobHoldUntil, the category is class JobHoldUntil itself.
133 *
134 * @return Printing attribute class (category), an instance of class
135 * {@link java.lang.Class java.lang.Class}.
136 */
137 public final Class<? extends Attribute> getCategory() {
138 return JobHoldUntil.class;
139 }
140
141 /**
142 * Get the name of the category of which this attribute value is an
143 * instance.
144 * <P>
145 * For class JobHoldUntil, the category name is <CODE>"job-hold-until"</CODE>.
146 *
147 * @return Attribute category name.
148 */
149 public final String getName() {
150 return "job-hold-until";
151 }
152
153}