You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EventSeverity.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.events.model;
  19. import java.io.ObjectStreamException;
  20. import java.io.Serializable;
  21. /** Enumeration class for event severities. */
  22. public final class EventSeverity implements Serializable {
  23. private static final long serialVersionUID = 4108175215810759243L;
  24. /** info level */
  25. public static final EventSeverity INFO = new EventSeverity("INFO");
  26. /** warning level */
  27. public static final EventSeverity WARN = new EventSeverity("WARN");
  28. /** error level */
  29. public static final EventSeverity ERROR = new EventSeverity("ERROR");
  30. /** fatal error */
  31. public static final EventSeverity FATAL = new EventSeverity("FATAL");
  32. private String name;
  33. /**
  34. * Constructor to add a new named item.
  35. * @param name Name of the item.
  36. */
  37. private EventSeverity(String name) {
  38. this.name = name;
  39. }
  40. /** @return the name of the enumeration */
  41. public String getName() {
  42. return this.name;
  43. }
  44. /**
  45. * Returns the enumeration/singleton object based on its name.
  46. * @param name the name of the enumeration value
  47. * @return the enumeration object
  48. */
  49. public static EventSeverity valueOf(String name) {
  50. if (INFO.getName().equalsIgnoreCase(name)) {
  51. return INFO;
  52. } else if (WARN.getName().equalsIgnoreCase(name)) {
  53. return WARN;
  54. } else if (ERROR.getName().equalsIgnoreCase(name)) {
  55. return ERROR;
  56. } else if (FATAL.getName().equalsIgnoreCase(name)) {
  57. return FATAL;
  58. } else {
  59. throw new IllegalArgumentException("Illegal value for enumeration: " + name);
  60. }
  61. }
  62. private Object readResolve() throws ObjectStreamException {
  63. return valueOf(getName());
  64. }
  65. /** {@inheritDoc} */
  66. public String toString() {
  67. return "EventSeverity:" + name;
  68. }
  69. }