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