1 /* 2 * Copyright (c) 2000, 2004, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package javax.print.attribute.standard; 26 27 import java.util.Date; 28 import javax.print.attribute.Attribute; 29 import javax.print.attribute.DateTimeSyntax; 30 import javax.print.attribute.PrintRequestAttribute; 31 import 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 * 82 * @author Alan Kaminsky 83 */ 84 public final class JobHoldUntil extends DateTimeSyntax 85 implements PrintRequestAttribute, PrintJobAttribute { 86 87 private static final long serialVersionUID = -1664471048860415024L; 88 89 90 /** 91 * Construct a new job hold until date-time attribute with the given 92 * {@link java.util.Date Date} value. 93 * 94 * @param dateTime {@link java.util.Date Date} value. 95 * 96 * @exception NullPointerException 97 * (unchecked exception) Thrown if <CODE>dateTime</CODE> is null. 98 */ 99 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 /** 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 class 134 * {@link java.lang.Class java.lang.Class}. 135 */ 136 public final Class<? extends Attribute> getCategory() { 137 return JobHoldUntil.class; 138 } 139 140 /** 141 * Get the name of the category of which this attribute value is an 142 * instance. 143 * <P> 144 * For class JobHoldUntil, the category name is <CODE>"job-hold-until"</CODE>. 145 * 146 * @return Attribute category name. 147 */ 148 public final String getName() { 149 return "job-hold-until"; 150 } 151 152 }