jdk/src/share/classes/javax/print/attribute/standard/Severity.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2004 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.print.attribute.standard;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import javax.print.attribute.EnumSyntax;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.print.attribute.Attribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Class Severity is a printing attribute class, an enumeration, that denotes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * the severity of a {@link PrinterStateReason PrinterStateReason} attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Instances of Severity do not appear in a Print Service's attribute set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * directly. Rather, a {@link PrinterStateReasons PrinterStateReasons}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * attribute appears in the Print Service's attribute set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *  The {@link PrinterStateReasons
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * PrinterStateReasons} attribute contains zero, one, or more than one {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * PrinterStateReason PrinterStateReason} objects which pertain to the Print
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Service's status, and each {@link PrinterStateReason PrinterStateReason}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * object is associated with a Severity level of REPORT (least severe),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * WARNING, or ERROR (most severe).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * The printer adds a {@link PrinterStateReason
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * PrinterStateReason} object to the Print Service's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * {@link PrinterStateReasons PrinterStateReasons} attribute when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * corresponding condition becomes true
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * of the printer, and the printer removes the {@link PrinterStateReason
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * PrinterStateReason} object again when the corresponding condition becomes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * false, regardless of whether the Print Service's overall
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * {@link PrinterState PrinterState} also changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <B>IPP Compatibility:</B>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <code>Severity.toString()</code> returns either "error", "warning", or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * "report".  The string values returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * each individual {@link PrinterStateReason} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * associated {@link Severity} object's <CODE>toString()</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * methods, concatenated together with a hyphen (<CODE>"-"</CODE>) in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * between, gives the IPP keyword value for a {@link PrinterStateReasons}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * The category name returned by <CODE>getName()</CODE> gives the IPP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * attribute name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @author  Alan Kaminsky
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
public final class Severity extends EnumSyntax implements Attribute {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static final long serialVersionUID = 8781881462717925380L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * "report" (least severe). An implementation may choose to omit some or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * all reports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Some reports specify finer granularity about the printer state;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * others serve as a precursor to a warning. A report must contain nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * that could affect the printed output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public static final Severity REPORT = new Severity (0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * "warning." An implementation may choose to omit some or all warnings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Warnings serve as a precursor to an error. A warning must contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * nothing  that prevents a job from completing, though in some cases the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * output may be of lower quality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public static final Severity WARNING = new Severity (1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Indicates that the {@link PrinterStateReason PrinterStateReason} is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * "error" (most severe). An implementation must include all errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * If this attribute contains one or more errors, the printer's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * {@link PrinterState PrinterState} must be STOPPED.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public static final Severity ERROR = new Severity (2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Construct a new severity enumeration value with the given integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param  value  Integer value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    protected Severity(int value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        super (value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    private static final String[] myStringTable = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        "report",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        "warning",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        "error"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    private static final Severity[] myEnumValueTable = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        REPORT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        WARNING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        ERROR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Returns the string table for class Severity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    protected String[] getStringTable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return myStringTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Returns the enumeration value table for class Severity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    protected EnumSyntax[] getEnumValueTable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        return myEnumValueTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Get the printing attribute class which is to be used as the "category"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * for this printing attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * For class Severity, the category is class Severity itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @return  Printing attribute class (category), an instance of class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *          {@link java.lang.Class java.lang.Class}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public final Class<? extends Attribute> getCategory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        return Severity.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Get the name of the category of which this attribute value is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * For class Severit, the category name is <CODE>"severity"</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @return  Attribute category name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public final String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return "severity";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
}