Path: blob/master/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsProcessed.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;2829import javax.print.attribute.Attribute;30import javax.print.attribute.IntegerSyntax;31import javax.print.attribute.PrintJobAttribute;3233/**34* Class {@code JobKOctetsProcessed} is an integer valued printing attribute35* class that specifies the total number of print data octets processed so far36* in K octets, i.e., in units of 1024 octets. The value must be rounded up, so37* that a job between 1 and 1024 octets inclusive must be indicated as being 1K38* octets, 1025 to 2048 inclusive must be 2K, etc. For a multidoc print job (a39* job with multiple documents), the JobKOctetsProcessed value is computed by40* adding up the individual documents' number of octets processed so far, then41* rounding up to the next K octets value.42* <p>43* The {@code JobKOctetsProcessed} attribute describes the progress of the job.44* This attribute is intended to be a counter. That is, the JobKOctetsProcessed45* value for a job that has not started processing must be 0. When the job's46* {@link JobState JobState} is {@code PROCESSING} or47* {@code PROCESSING_STOPPED}, the {@code JobKOctetsProcessed} value is intended48* to increase as the job is processed; it indicates the amount of the job that49* has been processed at the time the Print Job's attribute set is queried or at50* the time a print job event is reported. When the job enters the51* {@code COMPLETED}, {@code CANCELED}, or {@code ABORTED} states, the52* {@code JobKOctetsProcessed} value is the final value for the job.53* <p>54* For implementations where multiple copies are produced by the interpreter55* with only a single pass over the data, the final value of the56* JobKOctetsProcessed attribute must be equal to the value of the57* {@link JobKOctets JobKOctets} attribute. For implementations where multiple58* copies are produced by the interpreter by processing the data for each copy,59* the final value must be a multiple of the value of the60* {@link JobKOctets JobKOctets} attribute.61* <p>62* <b>IPP Compatibility:</b> The integer value gives the IPP integer value. The63* category name returned by {@code getName()} gives the IPP attribute name.64*65* @author Alan Kaminsky66* @see JobKOctets67* @see JobKOctetsSupported68* @see JobImpressionsCompleted69* @see JobMediaSheetsCompleted70*/71public final class JobKOctetsProcessed extends IntegerSyntax72implements PrintJobAttribute {7374/**75* Use serialVersionUID from JDK 1.4 for interoperability.76*/77@Serial78private static final long serialVersionUID = -6265238509657881806L;7980/**81* Construct a new job K octets processed attribute with the given integer82* value.83*84* @param value Integer value85* @throws IllegalArgumentException if {@code value} is negative86*/87public JobKOctetsProcessed(int value) {88super (value, 0, Integer.MAX_VALUE);89}9091/**92* Returns whether this job K octets processed attribute is equivalent to93* the passed in object. To be equivalent, all of the following conditions94* must be true:95* <ol type=1>96* <li>{@code object} is not {@code null}.97* <li>{@code object} is an instance of class {@code JobKOctetsProcessed}.98* <li>This job K octets processed attribute's value and {@code object}'s99* value are equal.100* </ol>101*102* @param object {@code Object} to compare to103* @return {@code true} if {@code object} is equivalent to this job K octets104* processed attribute, {@code false} otherwise105*/106public boolean equals(Object object) {107return(super.equals (object) &&108object instanceof JobKOctetsProcessed);109}110111/**112* Get the printing attribute class which is to be used as the "category"113* for this printing attribute value.114* <p>115* For class {@code JobKOctetsProcessed}, the category is class116* {@code JobKOctetsProcessed} itself.117*118* @return printing attribute class (category), an instance of class119* {@link Class java.lang.Class}120*/121public final Class<? extends Attribute> getCategory() {122return JobKOctetsProcessed.class;123}124125/**126* Get the name of the category of which this attribute value is an127* instance.128* <p>129* For class {@code JobKOctetsProcessed}, the category name is130* {@code "job-k-octets-processed"}.131*132* @return attribute category name133*/134public final String getName() {135return "job-k-octets-processed";136}137}138139140