Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/print/attribute/standard/JobHoldUntil.java
38918 views
/*1* Copyright (c) 2000, 2004, 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*/24package javax.print.attribute.standard;2526import java.util.Date;27import javax.print.attribute.Attribute;28import javax.print.attribute.DateTimeSyntax;29import javax.print.attribute.PrintRequestAttribute;30import javax.print.attribute.PrintJobAttribute;3132/**33* Class JobHoldUntil is a printing attribute class, a date-time attribute, that34* specifies the exact date and time at which the job must become a candidate35* for printing.36* <P>37* If the value of this attribute specifies a date-time that is in the future,38* the printer should add the {@link JobStateReason JobStateReason} value of39* JOB_HOLD_UNTIL_SPECIFIED to the job's {@link JobStateReasons JobStateReasons}40* attribute, must move the job to the PENDING_HELD state, and must not schedule41* the job for printing until the specified date-time arrives.42* <P>43* When the specified date-time arrives, the printer must remove the {@link44* JobStateReason JobStateReason} value of JOB_HOLD_UNTIL_SPECIFIED from the45* job's {@link JobStateReasons JobStateReasons} attribute, if present. If there46* are no other job state reasons that keep the job in the PENDING_HELD state,47* the printer must consider the job as a candidate for processing by moving the48* job to the PENDING state.49* <P>50* If the specified date-time has already passed, the job must be a candidate51* for processing immediately. Thus, one way to make the job immediately become52* a candidate for processing is to specify a JobHoldUntil attribute constructed53* like this (denoting a date-time of January 1, 1970, 00:00:00 GMT):54* <PRE>55* JobHoldUntil immediately = new JobHoldUntil (new Date (0L));56* </PRE>57* <P>58* If the client does not supply this attribute in a Print Request and the59* printer supports this attribute, the printer must use its60* (implementation-dependent) default JobHoldUntil value at job submission time61* (unlike most job template attributes that are used if necessary at job62* processing time).63* <P>64* To construct a JobHoldUntil attribute from separate values of the year,65* month, day, hour, minute, and so on, use a {@link java.util.Calendar66* Calendar} object to construct a {@link java.util.Date Date} object, then use67* the {@link java.util.Date Date} object to construct the JobHoldUntil68* attribute. To convert a JobHoldUntil attribute to separate values of the69* year, month, day, hour, minute, and so on, create a {@link java.util.Calendar70* Calendar} object and set it to the {@link java.util.Date Date} from the71* JobHoldUntil attribute.72* <P>73* <B>IPP Compatibility:</B> Although IPP supports a "job-hold-until" attribute74* specified as a keyword, IPP does not at this time support a "job-hold-until"75* attribute specified as a date and time. However, the date and time can be76* converted to one of the standard IPP keywords with some loss of precision;77* for example, a JobHoldUntil value with today's date and 9:00pm local time78* might be converted to the standard IPP keyword "night". The category name79* returned by <CODE>getName()</CODE> gives the IPP attribute name.80* <P>81*82* @author Alan Kaminsky83*/84public final class JobHoldUntil extends DateTimeSyntax85implements PrintRequestAttribute, PrintJobAttribute {8687private static final long serialVersionUID = -1664471048860415024L;888990/**91* Construct a new job hold until date-time attribute with the given92* {@link java.util.Date Date} value.93*94* @param dateTime {@link java.util.Date Date} value.95*96* @exception NullPointerException97* (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.98*/99public JobHoldUntil(Date dateTime) {100super (dateTime);101}102103/**104* Returns whether this job hold until attribute is equivalent to the105* passed in object. To be equivalent, all of the following conditions106* 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 and114* <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 hold120* until attribute, false otherwise.121*/122public boolean equals(Object object) {123return (super.equals(object) && object instanceof JobHoldUntil);124}125126127/**128* Get the printing attribute class which is to be used as the "category"129* for this printing attribute value.130* <P>131* For class JobHoldUntil, the category is class JobHoldUntil itself.132*133* @return Printing attribute class (category), an instance of class134* {@link java.lang.Class java.lang.Class}.135*/136public final Class<? extends Attribute> getCategory() {137return JobHoldUntil.class;138}139140/**141* Get the name of the category of which this attribute value is an142* instance.143* <P>144* For class JobHoldUntil, the category name is <CODE>"job-hold-until"</CODE>.145*146* @return Attribute category name.147*/148public final String getName() {149return "job-hold-until";150}151152}153154155