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.EnumSyntax;
  30 
  31 /**
  32  * Class {@code Severity} is a printing attribute class, an enumeration, that
  33  * denotes the severity of a {@link PrinterStateReason PrinterStateReason}
  34  * attribute.
  35  * <p>
  36  * Instances of {@code Severity} do not appear in a Print Service's attribute
  37  * set directly. Rather, a {@link PrinterStateReasons PrinterStateReasons}
  38  * attribute appears in the Print Service's attribute set.
  39  * The {@link PrinterStateReasons PrinterStateReasons} attribute contains zero,
  40  * one, or more than one {@link PrinterStateReason PrinterStateReason} objects
  41  * which pertain to the Print Service's status, and each
  42  * {@link PrinterStateReason PrinterStateReason} object is associated with a
  43  * Severity level of {@code REPORT} (least severe), {@code WARNING}, or
  44  * {@code ERROR} (most severe). The printer adds a
  45  * {@link PrinterStateReason PrinterStateReason} object to the Print Service's
  46  * {@link PrinterStateReasons PrinterStateReasons} attribute when the
  47  * corresponding condition becomes true of the printer, and the printer removes
  48  * the {@link PrinterStateReason PrinterStateReason} object again when the
  49  * corresponding condition becomes false, regardless of whether the Print
  50  * Service's overall {@link PrinterState PrinterState} also changed.
  51  * <p>
  52  * <b>IPP Compatibility:</b> {@code Severity.toString()} returns either "error",
  53  * "warning", or "report". The string values returned by each individual
  54  * {@link PrinterStateReason} and associated {@link Severity} object's
  55  * {@code toString()} methods, concatenated together with a hyphen ({@code "-"})
  56  * in between, gives the IPP keyword value for a {@link PrinterStateReasons}.
  57  * The category name returned by {@code getName()} gives the IPP attribute name.
  58  *
  59  * @author Alan Kaminsky
  60  */
  61 public final class Severity extends EnumSyntax implements Attribute {
  62 
  63     /**
  64      * Use serialVersionUID from JDK 1.4 for interoperability.
  65      */
  66     private static final long serialVersionUID = 8781881462717925380L;
  67 
  68     /**
  69      * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
  70      * "report" (least severe). An implementation may choose to omit some or all
  71      * reports. Some reports specify finer granularity about the printer state;
  72      * others serve as a precursor to a warning. A report must contain nothing
  73      * that could affect the printed output.
  74      */
  75     public static final Severity REPORT = new Severity (0);
  76 
  77     /**
  78      * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
  79      * "warning." An implementation may choose to omit some or all warnings.
  80      * Warnings serve as a precursor to an error. A warning must contain nothing
  81      * that prevents a job from completing, though in some cases the output may
  82      * be of lower quality.
  83      */
  84     public static final Severity WARNING = new Severity (1);
  85 
  86     /**
  87      * Indicates that the {@link PrinterStateReason PrinterStateReason} is an
  88      * "error" (most severe). An implementation must include all errors. If this
  89      * attribute contains one or more errors, the printer's
  90      * {@link PrinterState PrinterState} must be {@code STOPPED}.
  91      */
  92     public static final Severity ERROR = new Severity (2);
  93 
  94     /**
  95      * Construct a new severity enumeration value with the given integer value.
  96      *
  97      * @param  value Integer value
  98      */
  99     protected Severity(int value) {
 100         super (value);
 101     }
 102 
 103     /**
 104      * The string table for class {@code Severity}.
 105      */
 106     private static final String[] myStringTable = {
 107         "report",
 108         "warning",
 109         "error"
 110     };
 111 
 112     /**
 113      * The enumeration value table for class {@code Severity}.
 114      */
 115     private static final Severity[] myEnumValueTable = {
 116         REPORT,
 117         WARNING,
 118         ERROR
 119     };
 120 
 121     /**
 122      * Returns the string table for class {@code Severity}.
 123      */
 124     protected String[] getStringTable() {
 125         return myStringTable;
 126     }
 127 
 128     /**
 129      * Returns the enumeration value table for class {@code Severity}.
 130      */
 131     protected EnumSyntax[] getEnumValueTable() {
 132         return myEnumValueTable;
 133     }
 134 
 135     /**
 136      * Get the printing attribute class which is to be used as the "category"
 137      * for this printing attribute value.
 138      * <p>
 139      * For class {@code Severity}, the category is class
 140      * {@code Severity} itself.
 141      *
 142      * @return printing attribute class (category), an instance of class
 143      *         {@link Class java.lang.Class}
 144      */
 145     public final Class<? extends Attribute> getCategory() {
 146         return Severity.class;
 147     }
 148 
 149     /**
 150      * Get the name of the category of which this attribute value is an
 151      * instance.
 152      * <p>
 153      * For class {@code Severity}, the category name is {@code "severity"}.
 154      *
 155      * @return attribute category name
 156      */
 157     public final String getName() {
 158         return "severity";
 159     }
 160 }