]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.message.ui/src/org/simantics/message/ui/LogSession.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.message.ui / src / org / simantics / message / ui / LogSession.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.message.ui;
13
14 import com.ibm.icu.text.SimpleDateFormat;
15 import java.io.PrintWriter;
16 import java.text.ParseException;
17 import java.util.Date;
18
19 /**
20  * Group of entries with additional Session data.
21  */
22 public class LogSession extends Group {
23         private String sessionData;
24         private Date date;
25
26         public LogSession() {
27                 super(Messages.LogViewLabelProvider_Session);
28         }
29
30         public Date getDate() {
31                 return date;
32         }
33
34         public void setDate(String dateString) {
35                 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); //$NON-NLS-1$
36                 try {
37                         date = formatter.parse(dateString);
38                 } catch (ParseException e) { // do nothing
39                 }
40         }
41
42         public String getSessionData() {
43                 return sessionData;
44         }
45
46         void setSessionData(String data) {
47                 this.sessionData = data;
48         }
49
50         public void processLogLine(String line) {
51                 // process "!SESSION <dateUnknownFormat> ----------------------------"
52                 line = line.substring(9); // strip "!SESSION "
53                 int delim = line.indexOf("----"); //$NON-NLS-1$ // single "-" may be in date, so take few for sure
54                 if (delim == -1)
55                         return;
56
57                 String dateBuffer = line.substring(0, delim).trim();
58                 setDate(dateBuffer);
59         }
60
61         public void write(PrintWriter writer) {
62                 writer.write(sessionData);
63         }
64 }