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