KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > runtime > logview > LogSession


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.runtime.logview;
12
13 import java.text.ParseException JavaDoc;
14 import com.ibm.icu.text.SimpleDateFormat;
15 import java.util.Date JavaDoc;
16 import java.util.StringTokenizer JavaDoc;
17
18 public class LogSession {
19     private String JavaDoc sessionData;
20     private Date JavaDoc date;
21
22     /**
23      * Constructor for LogSession.
24      */

25     public LogSession() {
26     }
27
28     public Date JavaDoc getDate() {
29         return date;
30     }
31     
32     public void setDate(String JavaDoc dateString) {
33         SimpleDateFormat formatter = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss.SS"); //$NON-NLS-1$
34
try {
35             date = formatter.parse(dateString);
36         } catch (ParseException JavaDoc e) {
37         }
38     }
39     
40     public String JavaDoc getSessionData() {
41         return sessionData;
42     }
43
44     void setSessionData(String JavaDoc data) {
45         this.sessionData = data;
46     }
47     
48     public void processLogLine(String JavaDoc line) {
49         StringTokenizer JavaDoc tokenizer = new StringTokenizer JavaDoc(line);
50         if (tokenizer.countTokens() == 6) {
51             tokenizer.nextToken();
52             StringBuffer JavaDoc dateBuffer = new StringBuffer JavaDoc();
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 }
61
Popular Tags