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
.trace
.ITmfTrace
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.parsers
.custom
.CustomTxtTraceDefinition
.InputData
;
24 import org
.eclipse
.linuxtools
.tmf
.ui
.parsers
.custom
.CustomTxtTraceDefinition
.InputLine
;
26 public class CustomTxtEvent
extends CustomEvent
{
28 public CustomTxtEvent(CustomTxtTraceDefinition definition
) {
30 fType
= new CustomTxtEventType(definition
);
33 public CustomTxtEvent(CustomTxtTraceDefinition definition
, TmfEvent other
) {
34 super(definition
, other
);
37 public CustomTxtEvent(CustomTxtTraceDefinition definition
, ITmfTrace
<?
> parentTrace
, TmfTimestamp timestamp
, TmfEventSource source
, TmfEventType type
, TmfEventReference reference
) {
38 super(definition
, parentTrace
, timestamp
, source
, type
, reference
);
41 public CustomTxtEvent(CustomTxtTraceDefinition definition
, TmfTimestamp originalTS
, TmfTimestamp effectiveTS
, TmfEventSource source
, TmfEventType type
, TmfEventReference reference
) {
42 super(definition
, originalTS
, effectiveTS
, source
, type
, reference
);
45 public void processGroups(InputLine input
, Matcher matcher
) {
46 if (input
.columns
== null) {
49 for (int i
= 0; i
< input
.columns
.size(); i
++) {
50 InputData column
= input
.columns
.get(i
);
51 if (i
< matcher
.groupCount() && matcher
.group(i
+ 1) != null) {
52 String value
= matcher
.group(i
+ 1).trim();
53 if (value
.length() == 0) {
56 String name
= column
.name
;
57 if (column
.action
== CustomTxtTraceDefinition
.ACTION_SET
) {
58 fData
.put(name
, value
);
59 if (name
.equals(CustomTxtTraceDefinition
.TAG_TIMESTAMP
)) {
60 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, column
.format
);
62 } else if (column
.action
== CustomTxtTraceDefinition
.ACTION_APPEND
) {
63 String s
= fData
.get(name
);
65 fData
.put(name
, s
+ value
);
67 fData
.put(name
, value
);
69 if (name
.equals(CustomTxtTraceDefinition
.TAG_TIMESTAMP
)) {
70 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
71 if (timeStampInputFormat
!= null) {
72 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ column
.format
);
74 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, column
.format
);
77 } else if (column
.action
== CustomTxtTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
78 String s
= fData
.get(name
);
80 fData
.put(name
, s
+ " | " + value
); //$NON-NLS-1$
82 fData
.put(name
, value
);
84 if (name
.equals(CustomTxtTraceDefinition
.TAG_TIMESTAMP
)) {
85 String timeStampInputFormat
= fData
.get(TIMESTAMP_INPUT_FORMAT_KEY
);
86 if (timeStampInputFormat
!= null) {
87 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, timeStampInputFormat
+ " | " + column
.format
); //$NON-NLS-1$
89 fData
.put(TIMESTAMP_INPUT_FORMAT_KEY
, column
.format
);