blob: 4818a7441d18f09e401d2cd5b368d40122cd63a6 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2004 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25package javax.print.attribute.standard;
26
27import javax.print.attribute.EnumSyntax;
28import 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()</code> 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()</CODE>
57 * methods, concatenated together with a hyphen (<CODE>"-"</CODE>) in
58 * between, gives the IPP keyword value for a {@link PrinterStateReasons}.
59 * The category name returned by <CODE>getName()</CODE> gives the IPP
60 * attribute name.
61 * <P>
62 *
63 * @author Alan Kaminsky
64 */
65public final class Severity extends EnumSyntax implements Attribute {
66
67 private static final long serialVersionUID = 8781881462717925380L;
68
69 /**
70 * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
71 * "report" (least severe). An implementation may choose to omit some or
72 * all reports.
73 * Some reports specify finer granularity about the printer state;
74 * others serve as a precursor to a warning. A report must contain nothing
75 * that could affect the printed output.
76 */
77 public static final Severity REPORT = new Severity (0);
78
79 /**
80 * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
81 * "warning." An implementation may choose to omit some or all warnings.
82 * Warnings serve as a precursor to an error. A warning must contain
83 * nothing that prevents a job from completing, though in some cases the
84 * output may be of lower quality.
85 */
86 public static final Severity WARNING = new Severity (1);
87
88 /**
89 * Indicates that the {@link PrinterStateReason PrinterStateReason} is an
90 * "error" (most severe). An implementation must include all errors.
91 * If this attribute contains one or more errors, the printer's
92 * {@link PrinterState PrinterState} must be STOPPED.
93 */
94 public static final Severity ERROR = new Severity (2);
95
96 /**
97 * Construct a new severity enumeration value with the given integer
98 * value.
99 *
100 * @param value Integer value.
101 */
102 protected Severity(int value) {
103 super (value);
104 }
105
106 private static final String[] myStringTable = {
107 "report",
108 "warning",
109 "error"
110 };
111
112 private static final Severity[] myEnumValueTable = {
113 REPORT,
114 WARNING,
115 ERROR
116 };
117
118 /**
119 * Returns the string table for class Severity.
120 */
121 protected String[] getStringTable() {
122 return myStringTable;
123 }
124
125 /**
126 * Returns the enumeration value table for class Severity.
127 */
128 protected EnumSyntax[] getEnumValueTable() {
129 return myEnumValueTable;
130 }
131
132
133 /**
134 * Get the printing attribute class which is to be used as the "category"
135 * for this printing attribute value.
136 * <P>
137 * For class Severity, the category is class Severity itself.
138 *
139 * @return Printing attribute class (category), an instance of class
140 * {@link java.lang.Class java.lang.Class}.
141 */
142 public final Class<? extends Attribute> getCategory() {
143 return Severity.class;
144 }
145
146 /**
147 * Get the name of the category of which this attribute value is an
148 * instance.
149 * <P>
150 * For class Severit, the category name is <CODE>"severity"</CODE>.
151 *
152 * @return Attribute category name.
153 */
154 public final String getName() {
155 return "severity";
156 }
157
158}