1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */18package org.apache.hadoop.chukwa.extraction.demux.processor.mapper;
1920import java.text.ParseException;
21import java.text.SimpleDateFormat;
22import java.util.Date;
2324publicclassLogEntry {
25privatefinalstatic SimpleDateFormat sdf = new SimpleDateFormat(
26"yyyy-MM-dd HH:mm");
2728private Date date;
29private String logLevel;
30private String className;
31private String body;
3233publicLogEntry(String recordEntry) throws ParseException {
34 String dStr = recordEntry.substring(0, 23);
35 date = sdf.parse(dStr);
36int start = 24;
37int 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 }
4445public Date getDate() {
46return date;
47 }
4849publicvoid setDate(Date date) {
50this.date = date;
51 }
5253public String getLogLevel() {
54return logLevel;
55 }
5657public String getClassName() {
58return className;
59 }
6061public String getBody() {
62return body;
63 }
64 }