Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ErrorLevel.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2006-2007 Chris Smith, Shane Mc Cormack, Gregory Holmes
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.logger;
  23. /**
  24. * Specific error levels allowed by Logger.
  25. */
  26. public enum ErrorLevel {
  27. /** Fatal error. */
  28. FATAL("Fatal"),
  29. /** High priority error. */
  30. HIGH("High"),
  31. /** Medium priority error. */
  32. MEDIUM("Medium"),
  33. /** Low priority error. */
  34. LOW("Low"),
  35. /** Unknown priority error. */
  36. UNKNOWN("Unknown");
  37. /** toString value of the item. */
  38. private String value;
  39. /**
  40. * Instantiates the enum.
  41. *
  42. * @param value toString value
  43. */
  44. ErrorLevel(final String value) {
  45. this.value = value;
  46. }
  47. /** {@inheritDoc} */
  48. @Override
  49. public String toString() {
  50. return value;
  51. }
  52. /**
  53. * Returns if the specified error is more important than this one
  54. *
  55. * @param level Error level to compare
  56. *
  57. * @return true iif the error is more important
  58. */
  59. public boolean moreImportant(final ErrorLevel level) {
  60. switch (level) {
  61. case FATAL:
  62. return true;
  63. case HIGH:
  64. if (this == FATAL) {
  65. return true;
  66. }
  67. return false;
  68. case MEDIUM:
  69. if (this == HIGH || this == FATAL) {
  70. return true;
  71. }
  72. return false;
  73. case LOW:
  74. if (this == MEDIUM || this == HIGH || this == FATAL) {
  75. return true;
  76. }
  77. return false;
  78. case UNKNOWN:
  79. if (this == LOW || this == MEDIUM || this == HIGH || this == FATAL) {
  80. return true;
  81. }
  82. return false;
  83. default:
  84. return false;
  85. }
  86. }
  87. }