43b2dc59833caa410682222f7e81f402871e886b
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / logview / LogSession.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.debug.core.logview;
12
13 import java.text.ParseException;
14 import java.text.SimpleDateFormat;
15 import java.util.Date;
16 import java.util.StringTokenizer;
17
18 public class LogSession {
19         private String sessionData;
20         private Date date;
21
22         /**
23          * Constructor for LogSession.
24          */
25         public LogSession() {
26         }
27
28         public Date getDate() {
29                 return date;
30         }
31         
32         public void setDate(String 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 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 }