1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.parsers
.custom
;
15 import java
.util
.regex
.Matcher
;
17 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
18 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEventReference
;
19 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEventSource
;
20 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEventType
;
21 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimestamp
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.parsers
.custom
.CustomTxtTraceDefinition
.InputData
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.parsers
.custom
.CustomTxtTraceDefinition
.InputLine
;
25 public class CustomTxtEvent
extends CustomEvent
{
27 public CustomTxtEvent(CustomTxtTraceDefinition definition
, TmfEvent other
) {
28 super(definition
, other
);
31 public CustomTxtEvent(CustomTxtTraceDefinition definition
, TmfTimestamp timestamp
, TmfEventSource source
, TmfEventType type
, TmfEventReference reference
) {
32 super(definition
, timestamp
, source
, type
, reference
);
35 public CustomTxtEvent(CustomTxtTraceDefinition definition
, TmfTimestamp originalTS
, TmfTimestamp effectiveTS
, TmfEventSource source
, TmfEventType type
, TmfEventReference reference
) {
36 super(definition
, originalTS
, effectiveTS
, source
, type
, reference
);
39 public void processGroups(InputLine input
, Matcher matcher
) {
40 for (int i
= 0; i
< input
.columns
.size(); i
++) {
41 InputData column
= input
.columns
.get(i
);
42 if (i
< matcher
.groupCount() && matcher
.group(i
+ 1) != null) {
43 String value
= matcher
.group(i
+ 1).trim();
44 if (value
.length() == 0) {
47 String name
= column
.name
;
48 if (column
.action
== CustomTxtTraceDefinition
.ACTION_SET
) {
49 fData
.put(name
, value
);
50 if (name
.equals(CustomTxtTraceDefinition
.TAG_TIMESTAMP
)) {
51 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, column
.format
);
53 } else if (column
.action
== CustomTxtTraceDefinition
.ACTION_APPEND
) {
54 String s
= fData
.get(name
);
56 fData
.put(name
, s
+ value
);
58 fData
.put(name
, value
);
60 if (name
.equals(CustomTxtTraceDefinition
.TAG_TIMESTAMP
)) {
61 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
62 if (timeStampInputFormat
!= null) {
63 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ column
.format
);
65 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, column
.format
);
68 } else if (column
.action
== CustomTxtTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
69 String s
= fData
.get(name
);
71 fData
.put(name
, s
+ " | " + value
);
73 fData
.put(name
, value
);
75 if (name
.equals(CustomTxtTraceDefinition
.TAG_TIMESTAMP
)) {
76 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
77 if (timeStampInputFormat
!= null) {
78 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ " | " + column
.format
);
80 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, column
.format
);