1 16 package org.apache.log4j.lf5.viewer; 17 18 import java.util.Arrays ; 19 import java.util.HashMap ; 20 import java.util.List ; 21 import java.util.Map ; 22 23 29 30 32 public class LogTableColumn implements java.io.Serializable { 33 34 public final static LogTableColumn DATE = new LogTableColumn("Date"); 36 public final static LogTableColumn THREAD = new LogTableColumn("Thread"); 37 public final static LogTableColumn MESSAGE_NUM = new LogTableColumn("Message #"); 38 public final static LogTableColumn LEVEL = new LogTableColumn("Level"); 39 public final static LogTableColumn NDC = new LogTableColumn("NDC"); 40 public final static LogTableColumn CATEGORY = new LogTableColumn("Category"); 41 public final static LogTableColumn MESSAGE = new LogTableColumn("Message"); 42 public final static LogTableColumn LOCATION = new LogTableColumn("Location"); 43 public final static LogTableColumn THROWN = new LogTableColumn("Thrown"); 44 45 46 protected String _label; 50 51 private static LogTableColumn[] _log4JColumns; 55 private static Map _logTableColumnMap; 56 57 static { 61 _log4JColumns = new LogTableColumn[]{DATE, THREAD, MESSAGE_NUM, LEVEL, NDC, CATEGORY, 62 MESSAGE, LOCATION, THROWN}; 63 64 _logTableColumnMap = new HashMap (); 65 66 for (int i = 0; i < _log4JColumns.length; i++) { 67 _logTableColumnMap.put(_log4JColumns[i].getLabel(), _log4JColumns[i]); 68 } 69 } 70 71 72 public LogTableColumn(String label) { 73 _label = label; 74 } 75 76 80 83 public String getLabel() { 84 return _label; 85 } 86 87 95 public static LogTableColumn valueOf(String column) 96 throws LogTableColumnFormatException { 97 LogTableColumn tableColumn = null; 98 if (column != null) { 99 column = column.trim(); 100 tableColumn = (LogTableColumn) _logTableColumnMap.get(column); 101 } 102 103 if (tableColumn == null) { 104 StringBuffer buf = new StringBuffer (); 105 buf.append("Error while trying to parse (" + column + ") into"); 106 buf.append(" a LogTableColumn."); 107 throw new LogTableColumnFormatException(buf.toString()); 108 } 109 return tableColumn; 110 } 111 112 113 public boolean equals(Object o) { 114 boolean equals = false; 115 116 if (o instanceof LogTableColumn) { 117 if (this.getLabel() == 118 ((LogTableColumn) o).getLabel()) { 119 equals = true; 120 } 121 } 122 123 return equals; 124 } 125 126 public int hashCode() { 127 return _label.hashCode(); 128 } 129 130 public String toString() { 131 return _label; 132 } 133 134 138 public static List getLogTableColumns() { 139 return Arrays.asList(_log4JColumns); 140 } 141 142 public static LogTableColumn[] getLogTableColumnArray() { 143 return _log4JColumns; 144 } 145 146 150 154 158 } 159 160 161 162 163 164 165 | Popular Tags |