1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.log4j.lf5.viewer;
18
19 import java.util.Arrays;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23
24
25
26
27
28
29
30
31
32
33 public class LogTableColumn implements java.io.Serializable {
34 private static final long serialVersionUID = -4275827753626456547L;
35
36
37 public final static LogTableColumn DATE = new LogTableColumn("Date");
38 public final static LogTableColumn THREAD = new LogTableColumn("Thread");
39 public final static LogTableColumn MESSAGE_NUM = new LogTableColumn("Message #");
40 public final static LogTableColumn LEVEL = new LogTableColumn("Level");
41 public final static LogTableColumn NDC = new LogTableColumn("NDC");
42 public final static LogTableColumn CATEGORY = new LogTableColumn("Category");
43 public final static LogTableColumn MESSAGE = new LogTableColumn("Message");
44 public final static LogTableColumn LOCATION = new LogTableColumn("Location");
45 public final static LogTableColumn THROWN = new LogTableColumn("Thrown");
46
47
48
49
50
51 protected String _label;
52
53
54
55
56 private static LogTableColumn[] _log4JColumns;
57 private static Map _logTableColumnMap;
58
59
60
61
62 static {
63 _log4JColumns = new LogTableColumn[]{DATE, THREAD, MESSAGE_NUM, LEVEL, NDC, CATEGORY,
64 MESSAGE, LOCATION, THROWN};
65
66 _logTableColumnMap = new HashMap();
67
68 for (int i = 0; i < _log4JColumns.length; i++) {
69 _logTableColumnMap.put(_log4JColumns[i].getLabel(), _log4JColumns[i]);
70 }
71 }
72
73
74 public LogTableColumn(String label) {
75 _label = label;
76 }
77
78
79
80
81
82
83
84
85 public String getLabel() {
86 return _label;
87 }
88
89
90
91
92
93
94
95
96
97 public static LogTableColumn valueOf(String column)
98 throws LogTableColumnFormatException {
99 LogTableColumn tableColumn = null;
100 if (column != null) {
101 column = column.trim();
102 tableColumn = (LogTableColumn) _logTableColumnMap.get(column);
103 }
104
105 if (tableColumn == null) {
106 StringBuffer buf = new StringBuffer();
107 buf.append("Error while trying to parse (" + column + ") into");
108 buf.append(" a LogTableColumn.");
109 throw new LogTableColumnFormatException(buf.toString());
110 }
111 return tableColumn;
112 }
113
114
115 public boolean equals(Object o) {
116 boolean equals = false;
117
118 if (o instanceof LogTableColumn) {
119 if (this.getLabel() ==
120 ((LogTableColumn) o).getLabel()) {
121 equals = true;
122 }
123 }
124
125 return equals;
126 }
127
128 public int hashCode() {
129 return _label.hashCode();
130 }
131
132 public String toString() {
133 return _label;
134 }
135
136
137
138
139
140 public static List getLogTableColumns() {
141 return Arrays.asList(_log4JColumns);
142 }
143
144 public static LogTableColumn[] getLogTableColumnArray() {
145 return _log4JColumns;
146 }
147
148
149
150
151
152
153
154
155
156
157
158
159
160 }
161
162
163
164
165
166