1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.message.ui;
14 import com.ibm.icu.text.SimpleDateFormat;
15 import java.io.PrintWriter;
16 import java.text.ParseException;
17 import java.util.Date;
20 * Group of entries with additional Session data.
22 public class LogSession extends Group {
23 private String sessionData;
27 super(Messages.LogViewLabelProvider_Session);
30 public Date getDate() {
34 public void setDate(String dateString) {
35 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); //$NON-NLS-1$
37 date = formatter.parse(dateString);
38 } catch (ParseException e) { // do nothing
42 public String getSessionData() {
46 void setSessionData(String data) {
47 this.sessionData = data;
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
57 String dateBuffer = line.substring(0, delim).trim();
61 public void write(PrintWriter writer) {
62 writer.write(sessionData);