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
.internal
.tmf
.ui
.parsers
.custom
;
15 import java
.util
.regex
.Matcher
;
17 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomTxtTraceDefinition
.InputData
;
18 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomTxtTraceDefinition
.InputLine
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEventField
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfTimestamp
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEvent
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEventType
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
25 public class CustomTxtEvent
extends CustomEvent
{
27 public CustomTxtEvent(CustomTxtTraceDefinition definition
) {
29 setType(new CustomTxtEventType(definition
));
32 public CustomTxtEvent(CustomTxtTraceDefinition definition
, TmfEvent other
) {
33 super(definition
, other
);
36 public CustomTxtEvent(CustomTxtTraceDefinition definition
, ITmfTrace
<?
> parentTrace
, ITmfTimestamp timestamp
, String source
, TmfEventType type
, String reference
) {
37 super(definition
, parentTrace
, timestamp
, source
, type
, reference
);
41 public void setContent(ITmfEventField content
) {
42 super.setContent(content
);
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
);