1
2
3
4
5
6
7
8 package org.astrogrid.applications.beans.v1.cea.castor.types;
9
10
11
12
13
14 import java.io.Serializable;
15 import java.util.Enumeration;
16 import java.util.Hashtable;
17 import org.exolab.castor.xml.Marshaller;
18 import org.exolab.castor.xml.Unmarshaller;
19
20 /***
21 * Enumeration of possible message log levels
22 *
23 * @version $Revision: 1.34 $ $Date: 2007/01/04 16:26:20 $
24 */
25 public class LogLevel implements java.io.Serializable {
26
27
28
29
30
31
32 /***
33 * The info type
34 */
35 public static final int INFO_TYPE = 0;
36
37 /***
38 * The instance of the info type
39 */
40 public static final LogLevel INFO = new LogLevel(INFO_TYPE, "info");
41
42 /***
43 * The warn type
44 */
45 public static final int WARN_TYPE = 1;
46
47 /***
48 * The instance of the warn type
49 */
50 public static final LogLevel WARN = new LogLevel(WARN_TYPE, "warn");
51
52 /***
53 * The error type
54 */
55 public static final int ERROR_TYPE = 2;
56
57 /***
58 * The instance of the error type
59 */
60 public static final LogLevel ERROR = new LogLevel(ERROR_TYPE, "error");
61
62 /***
63 * Field _memberTable
64 */
65 private static java.util.Hashtable _memberTable = init();
66
67 /***
68 * Field type
69 */
70 private int type = -1;
71
72 /***
73 * Field stringValue
74 */
75 private java.lang.String stringValue = null;
76
77
78
79
80
81
82 private LogLevel(int type, java.lang.String value) {
83 super();
84 this.type = type;
85 this.stringValue = value;
86 }
87
88
89
90
91
92
93 /***
94 * Method enumerateReturns an enumeration of all possible
95 * instances of LogLevel
96 */
97 public static java.util.Enumeration enumerate()
98 {
99 return _memberTable.elements();
100 }
101
102 /***
103 * Method getTypeReturns the type of this LogLevel
104 */
105 public int getType()
106 {
107 return this.type;
108 }
109
110 /***
111 * Method init
112 */
113 private static java.util.Hashtable init()
114 {
115 Hashtable members = new Hashtable();
116 members.put("info", INFO);
117 members.put("warn", WARN);
118 members.put("error", ERROR);
119 return members;
120 }
121
122 /***
123 * Method toStringReturns the String representation of this
124 * LogLevel
125 */
126 public java.lang.String toString()
127 {
128 return this.stringValue;
129 }
130
131 /***
132 * Method valueOfReturns a new LogLevel based on the given
133 * String value.
134 *
135 * @param string
136 */
137 public static org.astrogrid.applications.beans.v1.cea.castor.types.LogLevel valueOf(java.lang.String string)
138 {
139 java.lang.Object obj = null;
140 if (string != null) obj = _memberTable.get(string);
141 if (obj == null) {
142 String err = "'" + string + "' is not a valid LogLevel";
143 throw new IllegalArgumentException(err);
144 }
145 return (LogLevel) obj;
146 }
147
148 }