File Source: ErrorLevel.java
1 /*
2 * Copyright (c) 2006-2009 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
23 package com.dmdirc.logger;
24
25 import com.dmdirc.ui.IconManager;
26
27 import javax.swing.Icon;
28
29 /** Specific error levels allowed by Logger. */
/*
P/P * Method: ErrorLevel valueOf(String)
*
* Postconditions:
* init'ed(return_value)
*/
30 public enum ErrorLevel {
31 /** Fatal error. */
/*
P/P * Method: com.dmdirc.logger.ErrorLevel__static_init
*
* Postconditions:
* "error"._tainted == 0
* "info"._tainted == 0
* "warning"._tainted == 0
* $VALUES == &new ErrorLevel[](ErrorLevel__static_init#6)
* FATAL == &new ErrorLevel(ErrorLevel__static_init#1)
* $VALUES[0] == &new ErrorLevel(ErrorLevel__static_init#1)
* HIGH == &new ErrorLevel(ErrorLevel__static_init#2)
* $VALUES[1] == &new ErrorLevel(ErrorLevel__static_init#2)
* LOW == &new ErrorLevel(ErrorLevel__static_init#4)
* $VALUES[3] == &new ErrorLevel(ErrorLevel__static_init#4)
* ...
*/
32 FATAL("Fatal", IconManager.getIconManager().getIcon("error")),
33 /** High priority error. */
34 HIGH("High", IconManager.getIconManager().getIcon("error")),
35 /** Medium priority error. */
36 MEDIUM("Medium", IconManager.getIconManager().getIcon("warning")),
37 /** Low priority error. */
38 LOW("Low", IconManager.getIconManager().getIcon("info")),
39 /** Unknown priority error. */
40 UNKNOWN("Unknown", IconManager.getIconManager().getIcon("info"));
41
42 /** Error level string. */
43 private String value;
44 /** Error level icon. */
45 private Icon icon;
46
47 /**
48 * Instantiates the enum.
49 *
50 * @param value toString value
51 */
/*
P/P * Method: void com.dmdirc.logger.ErrorLevel(String, int, String, Icon)
*
* Postconditions:
* this.icon == icon
* init'ed(this.icon)
* this.value == value
* init'ed(this.value)
*/
52 ErrorLevel(final String value, final Icon icon) {
53 this.value = value;
54 this.icon = icon;
55 }
56
57 /** {@inheritDoc} */
58 @Override
59 public String toString() {
/*
P/P * Method: String toString()
*
* Preconditions:
* init'ed(this.value)
*
* Postconditions:
* return_value == this.value
* init'ed(return_value)
*/
60 return value;
61 }
62
63 /**
64 * Error levels icon.
65 *
66 * @return Error levels icon
67 */
68 public Icon getIcon() {
/*
P/P * Method: Icon getIcon()
*
* Preconditions:
* init'ed(this.icon)
*
* Postconditions:
* return_value == this.icon
* init'ed(return_value)
*/
69 return icon;
70 }
71
72 /**
73 * Returns if the specified error is more important than this one
74 *
75 * @param level Error level to compare
76 *
77 * @return true iif the error is more important
78 */
79 public boolean moreImportant(final ErrorLevel level) {
/*
P/P * Method: bool moreImportant(ErrorLevel)
*
* Postconditions:
* init'ed(return_value)
*
* Test Vectors:
* level: Inverse{null}, Addr_Set{null}
*/
80 if (level == null) {
81 return false;
82 }
83
84 return ordinal() > level.ordinal();
85 }
86 }
SofCheck Inspector Build Version : 2.17854
| ErrorLevel.java |
2009-Jun-25 01:54:24 |
| ErrorLevel.class |
2009-Sep-02 17:04:14 |