01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.runtime.logview;
11:
12: import java.text.ParseException;
13: import com.ibm.icu.text.SimpleDateFormat;
14: import java.util.Date;
15: import java.util.StringTokenizer;
16:
17: public class LogSession {
18: private String sessionData;
19: private Date date;
20:
21: /**
22: * Constructor for LogSession.
23: */
24: public LogSession() {
25: }
26:
27: public Date getDate() {
28: return date;
29: }
30:
31: public void setDate(String dateString) {
32: SimpleDateFormat formatter = new SimpleDateFormat(
33: "MMM dd, yyyy HH:mm:ss.SS"); //$NON-NLS-1$
34: try {
35: date = formatter.parse(dateString);
36: } catch (ParseException e) {
37: }
38: }
39:
40: public String getSessionData() {
41: return sessionData;
42: }
43:
44: void setSessionData(String data) {
45: this .sessionData = data;
46: }
47:
48: public void processLogLine(String line) {
49: StringTokenizer tokenizer = new StringTokenizer(line);
50: if (tokenizer.countTokens() == 6) {
51: tokenizer.nextToken();
52: StringBuffer dateBuffer = new StringBuffer();
53: for (int i = 0; i < 4; i++) {
54: dateBuffer.append(tokenizer.nextToken());
55: dateBuffer.append(" "); //$NON-NLS-1$
56: }
57: setDate(dateBuffer.toString().trim());
58: }
59: }
60: }
|