001 /*
002 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.print.attribute.standard;
026
027 import javax.print.attribute.EnumSyntax;
028 import javax.print.attribute.Attribute;
029
030 /**
031 * Class Severity is a printing attribute class, an enumeration, that denotes
032 * the severity of a {@link PrinterStateReason PrinterStateReason} attribute.
033 * <P>
034 * Instances of Severity do not appear in a Print Service's attribute set
035 * directly. Rather, a {@link PrinterStateReasons PrinterStateReasons}
036 * attribute appears in the Print Service's attribute set.
037 * The {@link PrinterStateReasons
038 * PrinterStateReasons} attribute contains zero, one, or more than one {@link
039 * PrinterStateReason PrinterStateReason} objects which pertain to the Print
040 * Service's status, and each {@link PrinterStateReason PrinterStateReason}
041 * object is associated with a Severity level of REPORT (least severe),
042 * WARNING, or ERROR (most severe).
043 * The printer adds a {@link PrinterStateReason
044 * PrinterStateReason} object to the Print Service's
045 * {@link PrinterStateReasons PrinterStateReasons} attribute when the
046 * corresponding condition becomes true
047 * of the printer, and the printer removes the {@link PrinterStateReason
048 * PrinterStateReason} object again when the corresponding condition becomes
049 * false, regardless of whether the Print Service's overall
050 * {@link PrinterState PrinterState} also changed.
051 * <P>
052 * <B>IPP Compatibility:</B>
053 * <code>Severity.toString()</code> returns either "error", "warning", or
054 * "report". The string values returned by
055 * each individual {@link PrinterStateReason} and
056 * associated {@link Severity} object's <CODE>toString()</CODE>
057 * methods, concatenated together with a hyphen (<CODE>"-"</CODE>) in
058 * between, gives the IPP keyword value for a {@link PrinterStateReasons}.
059 * The category name returned by <CODE>getName()</CODE> gives the IPP
060 * attribute name.
061 * <P>
062 *
063 * @author Alan Kaminsky
064 */
065 public final class Severity extends EnumSyntax implements Attribute {
066
067 private static final long serialVersionUID = 8781881462717925380L;
068
069 /**
070 * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
071 * "report" (least severe). An implementation may choose to omit some or
072 * all reports.
073 * Some reports specify finer granularity about the printer state;
074 * others serve as a precursor to a warning. A report must contain nothing
075 * that could affect the printed output.
076 */
077 public static final Severity REPORT = new Severity(0);
078
079 /**
080 * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
081 * "warning." An implementation may choose to omit some or all warnings.
082 * Warnings serve as a precursor to an error. A warning must contain
083 * nothing that prevents a job from completing, though in some cases the
084 * output may be of lower quality.
085 */
086 public static final Severity WARNING = new Severity(1);
087
088 /**
089 * Indicates that the {@link PrinterStateReason PrinterStateReason} is an
090 * "error" (most severe). An implementation must include all errors.
091 * If this attribute contains one or more errors, the printer's
092 * {@link PrinterState PrinterState} must be STOPPED.
093 */
094 public static final Severity ERROR = new Severity(2);
095
096 /**
097 * Construct a new severity enumeration value with the given integer
098 * value.
099 *
100 * @param value Integer value.
101 */
102 protected Severity(int value) {
103 super (value);
104 }
105
106 private static final String[] myStringTable = { "report",
107 "warning", "error" };
108
109 private static final Severity[] myEnumValueTable = { REPORT,
110 WARNING, ERROR };
111
112 /**
113 * Returns the string table for class Severity.
114 */
115 protected String[] getStringTable() {
116 return myStringTable;
117 }
118
119 /**
120 * Returns the enumeration value table for class Severity.
121 */
122 protected EnumSyntax[] getEnumValueTable() {
123 return myEnumValueTable;
124 }
125
126 /**
127 * Get the printing attribute class which is to be used as the "category"
128 * for this printing attribute value.
129 * <P>
130 * For class Severity, the category is class Severity itself.
131 *
132 * @return Printing attribute class (category), an instance of class
133 * {@link java.lang.Class java.lang.Class}.
134 */
135 public final Class<? extends Attribute> getCategory() {
136 return Severity.class;
137 }
138
139 /**
140 * Get the name of the category of which this attribute value is an
141 * instance.
142 * <P>
143 * For class Severit, the category name is <CODE>"severity"</CODE>.
144 *
145 * @return Attribute category name.
146 */
147 public final String getName() {
148 return "severity";
149 }
150
151 }
|