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.SetOfIntegerSyntax;
  30 import javax.print.attribute.SupportedValuesAttribute;
  31 
  32 /**
  33  * Class {@code JobImpressionsSupported} is a printing attribute class, a set of
  34  * integers, that gives the supported values for a
  35  * {@link JobImpressions JobImpressions} attribute. It is restricted to a single
  36  * contiguous range of integers; multiple non-overlapping ranges are not
  37  * allowed. This gives the lower and upper bounds of the total sizes of print
  38  * jobs in number of impressions that the printer will accept.
  39  * <p>
  40  * <b>IPP Compatibility:</b> The {@code JobImpressionsSupported} attribute's
  41  * canonical array form gives the lower and upper bound for the range of values
  42  * to be included in an IPP "job-impressions-supported" attribute. See class
  43  * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for an explanation of canonical
  44  * array form. The category name returned by {@code getName()} gives the IPP
  45  * attribute name.
  46  *
  47  * @author Alan Kaminsky
  48  */
  49 public final class JobImpressionsSupported extends SetOfIntegerSyntax
  50         implements SupportedValuesAttribute {
  51 
  52     /**
  53      * Use serialVersionUID from JDK 1.4 for interoperability.
  54      */
  55     private static final long serialVersionUID = -4887354803843173692L;
  56 
  57     /**
  58      * Construct a new job impressions supported attribute containing a single
  59      * range of integers. That is, only those values of {@code JobImpressions}
  60      * in the one range are supported.
  61      *
  62      * @param  lowerBound lower bound of the range
  63      * @param  upperBound upper bound of the range
  64      * @throws IllegalArgumentException if a {@code null} range is specified or
  65      *         if a {@code non-null} range is specified with {@code lowerBound}
  66      *         less than zero
  67      */
  68     public JobImpressionsSupported(int lowerBound, int upperBound) {
  69         super (lowerBound, upperBound);
  70         if (lowerBound > upperBound) {
  71             throw new IllegalArgumentException("Null range specified");
  72         } else if (lowerBound < 0) {
  73             throw new IllegalArgumentException(
  74                                          "Job K octets value < 0 specified");
  75         }
  76     }
  77 
  78     /**
  79      * Returns whether this job impressions supported attribute is equivalent to
  80      * the passed in object. To be equivalent, all of the following conditions
  81      * must be true:
  82      * <ol type=1>
  83      *   <li>{@code object} is not {@code null}.
  84      *   <li>{@code object} is an instance of class
  85      *   {@code JobImpressionsSupported}.
  86      *   <li>This job impressions supported attribute's members and
  87      *   {@code object}'s members are the same.
  88      * </ol>
  89      *
  90      * @param  object {@code Object} to compare to
  91      * @return {@code true} if {@code object} is equivalent to this job
  92      *         impressions supported attribute, {@code false} otherwise
  93      */
  94     public boolean equals(Object object) {
  95         return (super.equals (object) &&
  96                 object instanceof JobImpressionsSupported);
  97     }
  98 
  99     /**
 100      * Get the printing attribute class which is to be used as the "category"
 101      * for this printing attribute value.
 102      * <p>
 103      * For class {@code JobImpressionsSupported}, the category is class
 104      * {@code JobImpressionsSupported} itself.
 105      *
 106      * @return printing attribute class (category), an instance of class
 107      *         {@link Class java.lang.Class}
 108      */
 109     public final Class<? extends Attribute> getCategory() {
 110         return JobImpressionsSupported.class;
 111     }
 112 
 113     /**
 114      * Get the name of the category of which this attribute value is an
 115      * instance.
 116      * <p>
 117      * For class {@code JobImpressionsSupported}, the category name is
 118      * {@code "job-impressions-supported"}.
 119      *
 120      * @return attribute category name
 121      */
 122     public final String getName() {
 123         return "job-impressions-supported";
 124     }
 125 }