2010-07-12 Francois Chouinard <fchouinar@gmail.com> Contributions for Bug319429...
[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 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) {
45 continue;
46 }
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);
52 }
53 } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND) {
54 String s = fData.get(name);
55 if (s != null) {
56 fData.put(name, s + value);
57 } else {
58 fData.put(name, value);
59 }
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);
64 } else {
65 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
66 }
67 }
68 } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
69 String s = fData.get(name);
70 if (s != null) {
71 fData.put(name, s + " | " + value);
72 } else {
73 fData.put(name, value);
74 }
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);
79 } else {
80 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
81 }
82 }
83 }
84 }
85 }
86 }
87
88 }
This page took 0.031476 seconds and 5 git commands to generate.