Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/JobHoldUntil.java
41171 views
/*1* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.print.attribute.standard;2627import java.io.Serial;28import java.util.Calendar;29import java.util.Date;3031import javax.print.attribute.Attribute;32import javax.print.attribute.DateTimeSyntax;33import javax.print.attribute.PrintJobAttribute;34import javax.print.attribute.PrintRequestAttribute;3536/**37* Class {@code JobHoldUntil} is a printing attribute class, a date-time38* attribute, that specifies the exact date and time at which the job must39* become a candidate for printing.40* <p>41* If the value of this attribute specifies a date-time that is in the future,42* the printer should add the {@link JobStateReason JobStateReason} value of43* {@code JOB_HOLD_UNTIL_SPECIFIED} to the job's44* {@link JobStateReasons JobStateReasons} attribute, must move the job to the45* {@code PENDING_HELD} state, and must not schedule the job for printing until46* the specified date-time arrives.47* <p>48* When the specified date-time arrives, the printer must remove the49* {@link JobStateReason JobStateReason} value of50* {@code JOB_HOLD_UNTIL_SPECIFIED} from the job's51* {@link JobStateReasons JobStateReasons} attribute, if present. If there are52* no other job state reasons that keep the job in the {@code PENDING_HELD}53* state, the printer must consider the job as a candidate for processing by54* moving the job to the PENDING state.55* <p>56* If the specified date-time has already passed, the job must be a candidate57* for processing immediately. Thus, one way to make the job immediately become58* a candidate for processing is to specify a {@code JobHoldUntil} attribute59* constructed like this60* (denoting a date-time of January 1, 1970, 00:00:00 GMT):61* <pre>62* JobHoldUntil immediately = new JobHoldUntil (new Date (0L));63* </pre>64* <p>65* If the client does not supply this attribute in a Print Request and the66* printer supports this attribute, the printer must use its67* (implementation-dependent) default {@code JobHoldUntil} value at job68* submission time (unlike most job template attributes that are used if69* necessary at job processing time).70* <p>71* To construct a {@code JobHoldUntil} attribute from separate values of the72* year, month, day, hour, minute, and so on, use a {@link Calendar Calendar}73* object to construct a {@link Date Date} object, then use the74* {@link Date Date} object to construct the {@code JobHoldUntil} attribute. To75* convert a {@code JobHoldUntil} attribute to separate values of the year,76* month, day, hour, minute, and so on, create a {@link Calendar Calendar}77* object and set it to the {@link Date Date} from the {@code JobHoldUntil}78* attribute.79* <p>80* <b>IPP Compatibility:</b> Although IPP supports a "job-hold-until" attribute81* specified as a keyword, IPP does not at this time support a "job-hold-until"82* attribute specified as a date and time. However, the date and time can be83* converted to one of the standard IPP keywords with some loss of precision;84* for example, a {@code JobHoldUntil} value with today's date and 9:00pm local85* time might be converted to the standard IPP keyword "night". The category86* name returned by {@code getName()} gives the IPP attribute name.87*88* @author Alan Kaminsky89*/90public final class JobHoldUntil extends DateTimeSyntax91implements PrintRequestAttribute, PrintJobAttribute {9293/**94* Use serialVersionUID from JDK 1.4 for interoperability.95*/96@Serial97private static final long serialVersionUID = -1664471048860415024L;9899/**100* Construct a new job hold until date-time attribute with the given101* {@link Date Date} value.102*103* @param dateTime {@link Date Date} value104* @throws NullPointerException if {@code dateTime} is {@code null}105*/106public JobHoldUntil(Date dateTime) {107super (dateTime);108}109110/**111* Returns whether this job hold until attribute is equivalent to the passed112* in object. To be equivalent, all of the following conditions must be113* true:114* <ol type=1>115* <li>{@code object} is not {@code null}.116* <li>{@code object} is an instance of class {@code JobHoldUntil}.117* <li>This job hold until attribute's {@link Date Date} value and118* {@code object}'s {@link Date Date} value are equal.119* </ol>120*121* @param object {@code Object} to compare to122* @return {@code true} if {@code object} is equivalent to this job hold123* until attribute, {@code false} otherwise124*/125public boolean equals(Object object) {126return (super.equals(object) && object instanceof JobHoldUntil);127}128129/**130* Get the printing attribute class which is to be used as the "category"131* for this printing attribute value.132* <p>133* For class {@code JobHoldUntil}, the category is class134* {@code JobHoldUntil} itself.135*136* @return printing attribute class (category), an instance of class137* {@link Class java.lang.Class}138*/139public final Class<? extends Attribute> getCategory() {140return JobHoldUntil.class;141}142143/**144* Get the name of the category of which this attribute value is an145* instance.146* <p>147* For class {@code JobHoldUntil}, the category name is148* {@code "job-hold-until"}.149*150* @return attribute category name151*/152public final String getName() {153return "job-hold-until";154}155}156157158