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 javax.print.attribute.Attribute; 28 import javax.print.attribute.IntegerSyntax; 29 import javax.print.attribute.PrintJobAttribute; 30 31 /** 32 * Class JobKOctetsProcessed is an integer valued printing attribute class that 33 * specifies the total number of print data octets processed so far in K octets, 34 * i.e., in units of 1024 octets. The value must be rounded up, so that a job 35 * between 1 and 1024 octets inclusive must be indicated as being 1K octets, 36 * 1025 to 2048 inclusive must be 2K, etc. For a multidoc print job (a job with 37 * multiple documents), the JobKOctetsProcessed value is computed by adding up 38 * the individual documents' number of octets processed so far, then rounding up 39 * to the next K octets value. 40 * <P> 41 * The JobKOctetsProcessed attribute describes the progress of the job. This 42 * attribute is intended to be a counter. That is, the JobKOctetsProcessed value 43 * for a job that has not started processing must be 0. When the job's {@link 44 * JobState JobState} is PROCESSING or PROCESSING_STOPPED, the 45 * JobKOctetsProcessed value is intended to increase as the job is processed; it 46 * indicates the amount of the job that has been processed at the time the Print 47 * Job's attribute set is queried or at the time a print job event is reported. 48 * When the job enters the COMPLETED, CANCELED, or ABORTED states, the 49 * JobKOctetsProcessed value is the final value for the job. 50 * <P> 51 * For implementations where multiple copies are produced by the interpreter 52 * with only a single pass over the data, the final value of the 53 * JobKOctetsProcessed attribute must be equal to the value of the {@link 54 * JobKOctets JobKOctets} attribute. For implementations where multiple copies 55 * are produced by the interpreter by processing the data for each copy, the 56 * final value must be a multiple of the value of the {@link JobKOctets 57 * JobKOctets} attribute. 58 * <P> 59 * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The 60 * category name returned by {@code getName()} gives the IPP attribute 61 * name. 62 * 63 * @see JobKOctets 64 * @see JobKOctetsSupported 65 * @see JobImpressionsCompleted 66 * @see JobMediaSheetsCompleted 67 * 68 * @author Alan Kaminsky 69 */ 70 public final class JobKOctetsProcessed extends IntegerSyntax 71 implements PrintJobAttribute { 72 73 private static final long serialVersionUID = -6265238509657881806L; 74 75 /** 76 * Construct a new job K octets processed attribute with the given integer 77 * value. 78 * 79 * @param value Integer value. 80 * 81 * @exception IllegalArgumentException 82 * (Unchecked exception) Thrown if {@code value} is less than 0. 83 */ 84 public JobKOctetsProcessed(int value) { 85 super (value, 0, Integer.MAX_VALUE); 86 } 87 88 /** 89 * Returns whether this job K octets processed attribute is equivalent to 90 * the passed in object. To be equivalent, all of the following conditions 91 * must be true: 92 * <OL TYPE=1> 93 * <LI> 94 * {@code object} is not null. 95 * <LI> 96 * {@code object} is an instance of class JobKOctetsProcessed. 97 * <LI> 98 * This job K octets processed attribute's value and 99 * {@code object}'s value are equal. 100 * </OL> 101 * 102 * @param object Object to compare to. 103 * 104 * @return True if {@code object} is equivalent to this job K 105 * octets processed attribute, false otherwise. 106 */ 107 public boolean equals(Object object) { 108 return(super.equals (object) && 109 object instanceof JobKOctetsProcessed); 110 } 111 112 /** 113 * Get the printing attribute class which is to be used as the "category" 114 * for this printing attribute value. 115 * <P> 116 * For class JobKOctetsProcessed, the category is class 117 * JobKOctetsProcessed itself. 118 * 119 * @return Printing attribute class (category), an instance of class 120 * {@link java.lang.Class java.lang.Class}. 121 */ 122 public final Class<? extends Attribute> getCategory() { 123 return JobKOctetsProcessed.class; 124 } 125 126 /** 127 * Get the name of the category of which this attribute value is an 128 * instance. 129 * <P> 130 * For class JobKOctetsProcessed, the category name is 131 * {@code "job-k-octets-processed"}. 132 * 133 * @return Attribute category name. 134 */ 135 public final String getName() { 136 return "job-k-octets-processed"; 137 } 138 139 } | 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 javax.print.attribute.Attribute; 29 import javax.print.attribute.IntegerSyntax; 30 import javax.print.attribute.PrintJobAttribute; 31 32 /** 33 * Class {@code JobKOctetsProcessed} is an integer valued printing attribute 34 * class that specifies the total number of print data octets processed so far 35 * in K octets, i.e., in units of 1024 octets. The value must be rounded up, so 36 * that a job between 1 and 1024 octets inclusive must be indicated as being 1K 37 * octets, 1025 to 2048 inclusive must be 2K, etc. For a multidoc print job (a 38 * job with multiple documents), the JobKOctetsProcessed value is computed by 39 * adding up the individual documents' number of octets processed so far, then 40 * rounding up to the next K octets value. 41 * <p> 42 * The {@code JobKOctetsProcessed} attribute describes the progress of the job. 43 * This attribute is intended to be a counter. That is, the JobKOctetsProcessed 44 * value for a job that has not started processing must be 0. When the job's 45 * {@link JobState JobState} is {@code PROCESSING} or 46 * {@code PROCESSING_STOPPED}, the {@code JobKOctetsProcessed} value is intended 47 * to increase as the job is processed; it indicates the amount of the job that 48 * has been processed at the time the Print Job's attribute set is queried or at 49 * the time a print job event is reported. When the job enters the 50 * {@code COMPLETED}, {@code CANCELED}, or {@code ABORTED} states, the 51 * {@code JobKOctetsProcessed} value is the final value for the job. 52 * <p> 53 * For implementations where multiple copies are produced by the interpreter 54 * with only a single pass over the data, the final value of the 55 * JobKOctetsProcessed attribute must be equal to the value of the 56 * {@link JobKOctets JobKOctets} attribute. For implementations where multiple 57 * copies are produced by the interpreter by processing the data for each copy, 58 * the final value must be a multiple of the value of the 59 * {@link JobKOctets JobKOctets} attribute. 60 * <p> 61 * <b>IPP Compatibility:</b> The integer value gives the IPP integer value. The 62 * category name returned by {@code getName()} gives the IPP attribute name. 63 * 64 * @author Alan Kaminsky 65 * @see JobKOctets 66 * @see JobKOctetsSupported 67 * @see JobImpressionsCompleted 68 * @see JobMediaSheetsCompleted 69 */ 70 public final class JobKOctetsProcessed extends IntegerSyntax 71 implements PrintJobAttribute { 72 73 /** 74 * Use serialVersionUID from JDK 1.4 for interoperability. 75 */ 76 private static final long serialVersionUID = -6265238509657881806L; 77 78 /** 79 * Construct a new job K octets processed attribute with the given integer 80 * value. 81 * 82 * @param value Integer value 83 * @throws IllegalArgumentException if {@code value} is negative 84 */ 85 public JobKOctetsProcessed(int value) { 86 super (value, 0, Integer.MAX_VALUE); 87 } 88 89 /** 90 * Returns whether this job K octets processed attribute is equivalent to 91 * the passed in object. To be equivalent, all of the following conditions 92 * must be true: 93 * <ol type=1> 94 * <li>{@code object} is not {@code null}. 95 * <li>{@code object} is an instance of class {@code JobKOctetsProcessed}. 96 * <li>This job K octets processed attribute's value and {@code object}'s 97 * value are equal. 98 * </ol> 99 * 100 * @param object {@code Object} to compare to 101 * @return {@code true} if {@code object} is equivalent to this job K octets 102 * processed attribute, {@code false} otherwise 103 */ 104 public boolean equals(Object object) { 105 return(super.equals (object) && 106 object instanceof JobKOctetsProcessed); 107 } 108 109 /** 110 * Get the printing attribute class which is to be used as the "category" 111 * for this printing attribute value. 112 * <p> 113 * For class {@code JobKOctetsProcessed}, the category is class 114 * {@code JobKOctetsProcessed} itself. 115 * 116 * @return printing attribute class (category), an instance of class 117 * {@link Class java.lang.Class} 118 */ 119 public final Class<? extends Attribute> getCategory() { 120 return JobKOctetsProcessed.class; 121 } 122 123 /** 124 * Get the name of the category of which this attribute value is an 125 * instance. 126 * <p> 127 * For class {@code JobKOctetsProcessed}, the category name is 128 * {@code "job-k-octets-processed"}. 129 * 130 * @return attribute category name 131 */ 132 public final String getName() { 133 return "job-k-octets-processed"; 134 } 135 } |