1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.chukwa.extraction.demux.processor.mapper;
19
20 import java.text.ParseException;
21 import java.text.SimpleDateFormat;
22 import java.util.Date;
23
24 public class LogEntry {
25 private final static SimpleDateFormat sdf = new SimpleDateFormat(
26 "yyyy-MM-dd HH:mm");
27
28 private Date date;
29 private String logLevel;
30 private String className;
31 private String body;
32
33 public LogEntry(String recordEntry) throws ParseException {
34 String dStr = recordEntry.substring(0, 23);
35 date = sdf.parse(dStr);
36 int start = 24;
37 int idx = recordEntry.indexOf(' ', start);
38 logLevel = recordEntry.substring(start, idx);
39 start = idx + 1;
40 idx = recordEntry.indexOf(' ', start);
41 className = recordEntry.substring(start, idx - 1);
42 body = recordEntry.substring(idx + 1);
43 }
44
45 public Date getDate() {
46 return date;
47 }
48
49 public void setDate(Date date) {
50 this.date = date;
51 }
52
53 public String getLogLevel() {
54 return logLevel;
55 }
56
57 public String getClassName() {
58 return className;
59 }
60
61 public String getBody() {
62 return body;
63 }
64 }