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 import javax.print.attribute.PrintRequestAttribute;
  32 
  33 /**
  34  * Class {@code JobPriority} is an integer valued printing attribute class that
  35  * specifies a print job's priority.
  36  * <p>
  37  * If a {@code JobPriority} attribute is specified for a Print Job, it specifies
  38  * a priority for scheduling the job. A higher value specifies a higher
  39  * priority. The value 1 indicates the lowest possible priority. The value 100
  40  * indicates the highest possible priority. Among those jobs that are ready to
  41  * print, a printer must print all jobs with a priority value of <i>n</i> before
  42  * printing those with a priority value of <i>n</i>-1 for all <i>n.</i>
  43  * <p>
  44  * If the client does not specify a {@code JobPriority} attribute for a Print
  45  * Job and the printer does support the JobPriority attribute, the printer must
  46  * use an implementation-defined default JobPriority value.
  47  * <p>
  48  * The client can always specify any job priority value from 1 to 100 for a job.
  49  * However, a Print Service instance may support fewer than 100 different job
  50  * priority levels. If this is the case, the Print Service instance
  51  * automatically maps the client-specified job priority value to one of the
  52  * supported job priority levels, dividing the 100 job priority values equally
  53  * among the available job priority levels.
  54  * <p>
  55  * <b>IPP Compatibility:</b> The integer value gives the IPP integer value. The
  56  * category name returned by {@code getName()} gives the IPP attribute name.
  57  *
  58  * @author Alan Kaminsky
  59  */
  60 public final class JobPriority extends IntegerSyntax
  61     implements PrintRequestAttribute, PrintJobAttribute {
  62 
  63     /**
  64      * Use serialVersionUID from JDK 1.4 for interoperability.
  65      */
  66     private static final long serialVersionUID = -4599900369040602769L;
  67 
  68     /**
  69      * Construct a new job priority attribute with the given integer value.
  70      *
  71      * @param  value Integer value
  72      * @throws IllegalArgumentException if {@code value} is less than 1 or
  73      *         greater than 100
  74      */
  75     public JobPriority(int value) {
  76         super (value, 1, 100);
  77     }
  78 
  79     /**
  80      * Returns whether this job priority attribute is equivalent to the passed
  81      * in object. To be equivalent, all of the following conditions must be
  82      * true:
  83      * <ol type=1>
  84      *   <li>{@code object} is not {@code null}.
  85      *   <li>{@code object} is an instance of class {@code JobPriority}.
  86      *   <li>This job priority attribute's value and {@code object}'s value are
  87      *   equal.
  88      * </ol>
  89      *
  90      * @param  object {@code Object} to compare to
  91      * @return {@code true} if {@code object} is equivalent to this job priority
  92      *         attribute, {@code false} otherwise
  93      */
  94     public boolean equals(Object object) {
  95         return (super.equals (object) && object instanceof JobPriority);
  96     }
  97 
  98     /**
  99      * Get the printing attribute class which is to be used as the "category"
 100      * for this printing attribute value.
 101      * <p>
 102      * For class {@code JobPriority}, the category is class
 103      * {@code JobPriority} itself.
 104      *
 105      * @return printing attribute class (category), an instance of class
 106      *         {@link Class java.lang.Class}
 107      */
 108     public final Class<? extends Attribute> getCategory() {
 109         return JobPriority.class;
 110     }
 111 
 112     /**
 113      * Get the name of the category of which this attribute value is an
 114      * instance.
 115      * <p>
 116      * For class {@code JobPriority}, the category name is
 117      * {@code "job-priority"}.
 118      *
 119      * @return attribute category name
 120      */
 121     public final String getName() {
 122         return "job-priority";
 123     }
 124 }