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 if (input
.columns
== null) {
43 for (int i
= 0; i
< input
.columns
.size(); i
++) {
44 InputData column
= input
.columns
.get(i
);
45 if (i
< matcher
.groupCount() && matcher
.group(i
+ 1) != null) {
46 String value
= matcher
.group(i
+ 1).trim();
47 if (value
.length() == 0) {
50 String name
= column
.name
;
51 if (column
.action
== CustomTxtTraceDefinition
.ACTION_SET
) {
52 fData
.put(name
, value
);
53 if (name
.equals(CustomTxtTraceDefinition
.TAG_TIMESTAMP
)) {
54 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, column
.format
);
56 } else if (column
.action
== CustomTxtTraceDefinition
.ACTION_APPEND
) {
57 String s
= fData
.get(name
);
59 fData
.put(name
, s
+ value
);
61 fData
.put(name
, value
);
63 if (name
.equals(CustomTxtTraceDefinition
.TAG_TIMESTAMP
)) {
64 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
65 if (timeStampInputFormat
!= null) {
66 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ column
.format
);
68 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, column
.format
);
71 } else if (column
.action
== CustomTxtTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
72 String s
= fData
.get(name
);
74 fData
.put(name
, s
+ " | " + value
); //$NON-NLS-1$
76 fData
.put(name
, value
);
78 if (name
.equals(CustomTxtTraceDefinition
.TAG_TIMESTAMP
)) {
79 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
80 if (timeStampInputFormat
!= null) {
81 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ " | " + column
.format
); //$NON-NLS-1$
83 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, column
.format
);