Fix for Bug338151
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / parsers / custom / CustomTxtEvent.java
1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.parsers.custom;
14
15 import java.util.regex.Matcher;
16
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;
24
25 public class CustomTxtEvent extends CustomEvent {
26
27 public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfEvent other) {
28 super(definition, other);
29 }
30
31 public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) {
32 super(definition, timestamp, source, type, reference);
33 }
34
35 public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source, TmfEventType type, TmfEventReference reference) {
36 super(definition, originalTS, effectiveTS, source, type, reference);
37 }
38
39 public void processGroups(InputLine input, Matcher matcher) {
40 if (input.columns == null) {
41 return;
42 }
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) {
48 continue;
49 }
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);
55 }
56 } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND) {
57 String s = fData.get(name);
58 if (s != null) {
59 fData.put(name, s + value);
60 } else {
61 fData.put(name, value);
62 }
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);
67 } else {
68 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
69 }
70 }
71 } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
72 String s = fData.get(name);
73 if (s != null) {
74 fData.put(name, s + " | " + value); //$NON-NLS-1$
75 } else {
76 fData.put(name, value);
77 }
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$
82 } else {
83 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
84 }
85 }
86 }
87 }
88 }
89 }
90
91 }
This page took 0.031905 seconds and 5 git commands to generate.