1 54 package org.w3c.tidy; 55 56 62 public final class TidyMessage 63 { 64 65 68 private int line; 69 70 74 private int column; 75 76 80 private Level level; 81 82 85 private String message; 86 87 90 private int errorCode; 91 92 100 public TidyMessage(int errorCode, int line, int column, Level level, String message) 101 { 102 this.errorCode = errorCode; 103 this.line = line; 104 this.column = column; 105 this.level = level; 106 this.message = message; 107 } 108 109 113 public int getErrorCode() 114 { 115 return this.errorCode; 116 } 117 118 122 public int getColumn() 123 { 124 return this.column; 125 } 126 127 131 public Level getLevel() 132 { 133 return this.level; 134 } 135 136 140 public int getLine() 141 { 142 return this.line; 143 } 144 145 149 public String getMessage() 150 { 151 return this.message; 152 } 153 154 159 public static final class Level implements Comparable 160 { 161 162 165 public static final Level SUMMARY = new Level(0); 166 167 170 public static final Level INFO = new Level(1); 171 172 175 public static final Level WARNING = new Level(2); 176 177 180 public static final Level ERROR = new Level(3); 181 182 185 private short code; 186 187 191 private Level(int code) 192 { 193 this.code = (short) code; 194 } 195 196 200 public short getCode() 201 { 202 return this.code; 203 } 204 205 210 public static Level fromCode(int code) 211 { 212 switch (code) 213 { 214 case 0 : 215 return SUMMARY; 216 case 1 : 217 return INFO; 218 case 2 : 219 return WARNING; 220 case 3 : 221 return ERROR; 222 223 default : 224 return null; 225 } 226 } 227 228 231 public int compareTo(Object object) 232 { 233 return this.code - ((Level) object).code; 234 } 235 236 239 public boolean equals(Object object) 240 { 241 if (!(object instanceof Level)) 242 { 243 return false; 244 } 245 return this.code == ((Level) object).code; 246 } 247 248 251 public String toString() 252 { 253 switch (code) 254 { 255 case 0 : 256 return "SUMMARY"; 257 case 1 : 258 return "INFO"; 259 case 2 : 260 return "WARNING"; 261 case 3 : 262 return "ERROR"; 263 264 default : 265 return "?"; 267 } 268 } 269 270 273 public int hashCode() 274 { 275 return super.hashCode(); 277 } 278 } 279 280 } | Popular Tags |