001 /*
002 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.print.attribute.standard;
026
027 import java.util.Date;
028 import javax.print.attribute.Attribute;
029 import javax.print.attribute.DateTimeSyntax;
030 import javax.print.attribute.PrintRequestAttribute;
031 import javax.print.attribute.PrintJobAttribute;
032
033 /**
034 * Class JobHoldUntil is a printing attribute class, a date-time attribute, that
035 * specifies the exact date and time at which the job must become a candidate
036 * for printing.
037 * <P>
038 * If the value of this attribute specifies a date-time that is in the future,
039 * the printer should add the {@link JobStateReason JobStateReason} value of
040 * JOB_HOLD_UNTIL_SPECIFIED to the job's {@link JobStateReasons JobStateReasons}
041 * attribute, must move the job to the PENDING_HELD state, and must not schedule
042 * the job for printing until the specified date-time arrives.
043 * <P>
044 * When the specified date-time arrives, the printer must remove the {@link
045 * JobStateReason JobStateReason} value of JOB_HOLD_UNTIL_SPECIFIED from the
046 * job's {@link JobStateReasons JobStateReasons} attribute, if present. If there
047 * are no other job state reasons that keep the job in the PENDING_HELD state,
048 * the printer must consider the job as a candidate for processing by moving the
049 * job to the PENDING state.
050 * <P>
051 * If the specified date-time has already passed, the job must be a candidate
052 * for processing immediately. Thus, one way to make the job immediately become
053 * a candidate for processing is to specify a JobHoldUntil attribute constructed
054 * like this (denoting a date-time of January 1, 1970, 00:00:00 GMT):
055 * <PRE>
056 * JobHoldUntil immediately = new JobHoldUntil (new Date (0L));
057 * </PRE>
058 * <P>
059 * If the client does not supply this attribute in a Print Request and the
060 * printer supports this attribute, the printer must use its
061 * (implementation-dependent) default JobHoldUntil value at job submission time
062 * (unlike most job template attributes that are used if necessary at job
063 * processing time).
064 * <P>
065 * To construct a JobHoldUntil attribute from separate values of the year,
066 * month, day, hour, minute, and so on, use a {@link java.util.Calendar
067 * Calendar} object to construct a {@link java.util.Date Date} object, then use
068 * the {@link java.util.Date Date} object to construct the JobHoldUntil
069 * attribute. To convert a JobHoldUntil attribute to separate values of the
070 * year, month, day, hour, minute, and so on, create a {@link java.util.Calendar
071 * Calendar} object and set it to the {@link java.util.Date Date} from the
072 * JobHoldUntil attribute.
073 * <P>
074 * <B>IPP Compatibility:</B> Although IPP supports a "job-hold-until" attribute
075 * specified as a keyword, IPP does not at this time support a "job-hold-until"
076 * attribute specified as a date and time. However, the date and time can be
077 * converted to one of the standard IPP keywords with some loss of precision;
078 * for example, a JobHoldUntil value with today's date and 9:00pm local time
079 * might be converted to the standard IPP keyword "night". The category name
080 * returned by <CODE>getName()</CODE> gives the IPP attribute name.
081 * <P>
082 *
083 * @author Alan Kaminsky
084 */
085 public final class JobHoldUntil extends DateTimeSyntax implements
086 PrintRequestAttribute, PrintJobAttribute {
087
088 private static final long serialVersionUID = -1664471048860415024L;
089
090 /**
091 * Construct a new job hold until date-time attribute with the given
092 * {@link java.util.Date Date} value.
093 *
094 * @param dateTime {@link java.util.Date Date} value.
095 *
096 * @exception NullPointerException
097 * (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.
098 */
099 public JobHoldUntil(Date dateTime) {
100 super (dateTime);
101 }
102
103 /**
104 * Returns whether this job hold until attribute is equivalent to the
105 * passed in object. To be equivalent, all of the following conditions
106 * must be true:
107 * <OL TYPE=1>
108 * <LI>
109 * <CODE>object</CODE> is not null.
110 * <LI>
111 * <CODE>object</CODE> is an instance of class JobHoldUntil.
112 * <LI>
113 * This job hold until attribute's {@link java.util.Date Date} value and
114 * <CODE>object</CODE>'s {@link java.util.Date Date} value are equal.
115 * </OL>
116 *
117 * @param object Object to compare to.
118 *
119 * @return True if <CODE>object</CODE> is equivalent to this job hold
120 * until attribute, false otherwise.
121 */
122 public boolean equals(Object object) {
123 return (super .equals(object) && object instanceof JobHoldUntil);
124 }
125
126 /**
127 * Get the printing attribute class which is to be used as the "category"
128 * for this printing attribute value.
129 * <P>
130 * For class JobHoldUntil, the category is class JobHoldUntil itself.
131 *
132 * @return Printing attribute class (category), an instance of class
133 * {@link java.lang.Class java.lang.Class}.
134 */
135 public final Class<? extends Attribute> getCategory() {
136 return JobHoldUntil.class;
137 }
138
139 /**
140 * Get the name of the category of which this attribute value is an
141 * instance.
142 * <P>
143 * For class JobHoldUntil, the category name is <CODE>"job-hold-until"</CODE>.
144 *
145 * @return Attribute category name.
146 */
147 public final String getName() {
148 return "job-hold-until";
149 }
150
151 }
|