1 /* 2 * Copyright (c) 2000, 2014, 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()} 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} 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} is not null. 110 * <LI> 111 * {@code object} 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}'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} 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"}. 145 * 146 * @return Attribute category name. 147 */ 148 public final String getName() { 149 return "job-hold-until"; 150 } 151 152 } | 1 /* 2 * Copyright (c) 2000, 2017, 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 26 package javax.print.attribute.standard; 27 28 import java.util.Calendar; 29 import java.util.Date; 30 31 import javax.print.attribute.Attribute; 32 import javax.print.attribute.DateTimeSyntax; 33 import javax.print.attribute.PrintJobAttribute; 34 import javax.print.attribute.PrintRequestAttribute; 35 36 /** 37 * Class {@code JobHoldUntil} is a printing attribute class, a date-time 38 * attribute, that specifies the exact date and time at which the job must 39 * 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 of 43 * {@code JOB_HOLD_UNTIL_SPECIFIED} to the job's 44 * {@link JobStateReasons JobStateReasons} attribute, must move the job to the 45 * {@code PENDING_HELD} state, and must not schedule the job for printing until 46 * the specified date-time arrives. 47 * <p> 48 * When the specified date-time arrives, the printer must remove the 49 * {@link JobStateReason JobStateReason} value of 50 * {@code JOB_HOLD_UNTIL_SPECIFIED} from the job's 51 * {@link JobStateReasons JobStateReasons} attribute, if present. If there are 52 * 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 by 54 * moving the job to the PENDING state. 55 * <p> 56 * If the specified date-time has already passed, the job must be a candidate 57 * for processing immediately. Thus, one way to make the job immediately become 58 * a candidate for processing is to specify a {@code JobHoldUntil} attribute 59 * constructed like this 60 * (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 the 66 * printer supports this attribute, the printer must use its 67 * (implementation-dependent) default {@code JobHoldUntil} value at job 68 * submission time (unlike most job template attributes that are used if 69 * necessary at job processing time). 70 * <p> 71 * To construct a {@code JobHoldUntil} attribute from separate values of the 72 * year, month, day, hour, minute, and so on, use a {@link Calendar Calendar} 73 * object to construct a {@link Date Date} object, then use the 74 * {@link Date Date} object to construct the {@code JobHoldUntil} attribute. To 75 * 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" attribute 81 * 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 be 83 * 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 local 85 * time might be converted to the standard IPP keyword "night". The category 86 * name returned by {@code getName()} gives the IPP attribute name. 87 * 88 * @author Alan Kaminsky 89 */ 90 public final class JobHoldUntil extends DateTimeSyntax 91 implements PrintRequestAttribute, PrintJobAttribute { 92 93 /** 94 * Use serialVersionUID from JDK 1.4 for interoperability. 95 */ 96 private static final long serialVersionUID = -1664471048860415024L; 97 98 /** 99 * Construct a new job hold until date-time attribute with the given 100 * {@link Date Date} value. 101 * 102 * @param dateTime {@link Date Date} value 103 * @throws NullPointerException if {@code dateTime} is {@code null} 104 */ 105 public JobHoldUntil(Date dateTime) { 106 super (dateTime); 107 } 108 109 /** 110 * Returns whether this job hold until attribute is equivalent to the passed 111 * in object. To be equivalent, all of the following conditions must be 112 * true: 113 * <ol type=1> 114 * <li>{@code object} is not {@code null}. 115 * <li>{@code object} is an instance of class {@code JobHoldUntil}. 116 * <li>This job hold until attribute's {@link Date Date} value and 117 * {@code object}'s {@link Date Date} value are equal. 118 * </ol> 119 * 120 * @param object {@code Object} to compare to 121 * @return {@code true} if {@code object} is equivalent to this job hold 122 * until attribute, {@code false} otherwise 123 */ 124 public boolean equals(Object object) { 125 return (super.equals(object) && object instanceof JobHoldUntil); 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 {@code JobHoldUntil}, the category is class 133 * {@code JobHoldUntil} itself. 134 * 135 * @return printing attribute class (category), an instance of class 136 * {@link Class java.lang.Class} 137 */ 138 public final Class<? extends Attribute> getCategory() { 139 return JobHoldUntil.class; 140 } 141 142 /** 143 * Get the name of the category of which this attribute value is an 144 * instance. 145 * <p> 146 * For class {@code JobHoldUntil}, the category name is 147 * {@code "job-hold-until"}. 148 * 149 * @return attribute category name 150 */ 151 public final String getName() { 152 return "job-hold-until"; 153 } 154 } |