1. /*
  2. * @(#)Severity.java 1.10 04/05/05
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.print.attribute.standard;
  8. import javax.print.attribute.EnumSyntax;
  9. import javax.print.attribute.Attribute;
  10. /**
  11. * Class Severity is a printing attribute class, an enumeration, that denotes
  12. * the severity of a {@link PrinterStateReason PrinterStateReason} attribute.
  13. * <P>
  14. * Instances of Severity do not appear in a Print Service's attribute set
  15. * directly. Rather, a {@link PrinterStateReasons PrinterStateReasons}
  16. * attribute appears in the Print Service's attribute set.
  17. * The {@link PrinterStateReasons
  18. * PrinterStateReasons} attribute contains zero, one, or more than one {@link
  19. * PrinterStateReason PrinterStateReason} objects which pertain to the Print
  20. * Service's status, and each {@link PrinterStateReason PrinterStateReason}
  21. * object is associated with a Severity level of REPORT (least severe),
  22. * WARNING, or ERROR (most severe).
  23. * The printer adds a {@link PrinterStateReason
  24. * PrinterStateReason} object to the Print Service's
  25. * {@link PrinterStateReasons PrinterStateReasons} attribute when the
  26. * corresponding condition becomes true
  27. * of the printer, and the printer removes the {@link PrinterStateReason
  28. * PrinterStateReason} object again when the corresponding condition becomes
  29. * false, regardless of whether the Print Service's overall
  30. * {@link PrinterState PrinterState} also changed.
  31. * <P>
  32. * <B>IPP Compatibility:</B>
  33. * <code>Severity.toString()</code> returns either "error", "warning", or
  34. * "report". The string values returned by
  35. * each individual {@link PrinterStateReason} and
  36. * associated {@link Severity} object's <CODE>toString()</CODE>
  37. * methods, concatenated together with a hyphen (<CODE>"-"</CODE>) in
  38. * between, gives the IPP keyword value for a {@link PrinterStateReasons}.
  39. * The category name returned by <CODE>getName()</CODE> gives the IPP
  40. * attribute name.
  41. * <P>
  42. *
  43. * @author Alan Kaminsky
  44. */
  45. public final class Severity extends EnumSyntax implements Attribute {
  46. private static final long serialVersionUID = 8781881462717925380L;
  47. /**
  48. * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
  49. * "report" (least severe). An implementation may choose to omit some or
  50. * all reports.
  51. * Some reports specify finer granularity about the printer state;
  52. * others serve as a precursor to a warning. A report must contain nothing
  53. * that could affect the printed output.
  54. */
  55. public static final Severity REPORT = new Severity (0);
  56. /**
  57. * Indicates that the {@link PrinterStateReason PrinterStateReason} is a
  58. * "warning." An implementation may choose to omit some or all warnings.
  59. * Warnings serve as a precursor to an error. A warning must contain
  60. * nothing that prevents a job from completing, though in some cases the
  61. * output may be of lower quality.
  62. */
  63. public static final Severity WARNING = new Severity (1);
  64. /**
  65. * Indicates that the {@link PrinterStateReason PrinterStateReason} is an
  66. * "error" (most severe). An implementation must include all errors.
  67. * If this attribute contains one or more errors, the printer's
  68. * {@link PrinterState PrinterState} must be STOPPED.
  69. */
  70. public static final Severity ERROR = new Severity (2);
  71. /**
  72. * Construct a new severity enumeration value with the given integer
  73. * value.
  74. *
  75. * @param value Integer value.
  76. */
  77. protected Severity(int value) {
  78. super (value);
  79. }
  80. private static final String[] myStringTable = {
  81. "report",
  82. "warning",
  83. "error"
  84. };
  85. private static final Severity[] myEnumValueTable = {
  86. REPORT,
  87. WARNING,
  88. ERROR
  89. };
  90. /**
  91. * Returns the string table for class Severity.
  92. */
  93. protected String[] getStringTable() {
  94. return myStringTable;
  95. }
  96. /**
  97. * Returns the enumeration value table for class Severity.
  98. */
  99. protected EnumSyntax[] getEnumValueTable() {
  100. return myEnumValueTable;
  101. }
  102. /**
  103. * Get the printing attribute class which is to be used as the "category"
  104. * for this printing attribute value.
  105. * <P>
  106. * For class Severity, the category is class Severity itself.
  107. *
  108. * @return Printing attribute class (category), an instance of class
  109. * {@link java.lang.Class java.lang.Class}.
  110. */
  111. public final Class<? extends Attribute> getCategory() {
  112. return Severity.class;
  113. }
  114. /**
  115. * Get the name of the category of which this attribute value is an
  116. * instance.
  117. * <P>
  118. * For class Severit, the category name is <CODE>"severity"</CODE>.
  119. *
  120. * @return Attribute category name.
  121. */
  122. public final String getName() {
  123. return "severity";
  124. }
  125. }