Re-structure LTTng sub-project as per the Linux Tools guidelines
[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.core.event.TmfEvent;
18 import org.eclipse.linuxtools.tmf.core.event.TmfEventReference;
19 import org.eclipse.linuxtools.tmf.core.event.TmfEventSource;
20 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
21 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
22 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
23 import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData;
24 import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;
25
26 public class CustomTxtEvent extends CustomEvent {
27
28 public CustomTxtEvent(CustomTxtTraceDefinition definition) {
29 super(definition);
30 fType = new CustomTxtEventType(definition);
31 }
32
33 public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfEvent other) {
34 super(definition, other);
35 }
36
37 public CustomTxtEvent(CustomTxtTraceDefinition definition, ITmfTrace<?> parentTrace, TmfTimestamp timestamp, TmfEventSource source, TmfEventType type, TmfEventReference reference) {
38 super(definition, parentTrace, timestamp, source, type, reference);
39 }
40
41 public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfTimestamp originalTS, TmfTimestamp effectiveTS, TmfEventSource source, TmfEventType type, TmfEventReference reference) {
42 super(definition, originalTS, effectiveTS, source, type, reference);
43 }
44
45 public void processGroups(InputLine input, Matcher matcher) {
46 if (input.columns == null) {
47 return;
48 }
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) {
54 continue;
55 }
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);
61 }
62 } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND) {
63 String s = fData.get(name);
64 if (s != null) {
65 fData.put(name, s + value);
66 } else {
67 fData.put(name, value);
68 }
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);
73 } else {
74 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
75 }
76 }
77 } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
78 String s = fData.get(name);
79 if (s != null) {
80 fData.put(name, s + " | " + value); //$NON-NLS-1$
81 } else {
82 fData.put(name, value);
83 }
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$
88 } else {
89 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
90 }
91 }
92 }
93 }
94 }
95 }
96
97 }
This page took 0.043361 seconds and 5 git commands to generate.