Change type of event source from TmfEventSource to String
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / parsers / custom / CustomTxtEvent.java
CommitLineData
c3c5c786
FC
1/*******************************************************************************\r
2 * Copyright (c) 2010 Ericsson\r
3 * \r
4 * All rights reserved. This program and the accompanying materials are\r
5 * made available under the terms of the Eclipse Public License v1.0 which\r
6 * accompanies this distribution, and is available at\r
7 * http://www.eclipse.org/legal/epl-v10.html\r
8 * \r
9 * Contributors:\r
10 * Patrick Tasse - Initial API and implementation\r
11 *******************************************************************************/\r
12\r
13package org.eclipse.linuxtools.tmf.ui.parsers.custom;\r
14\r
15import java.util.regex.Matcher;\r
16\r
6c13869b
FC
17import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
18import org.eclipse.linuxtools.tmf.core.event.TmfEventReference;\r
6c13869b
FC
19import org.eclipse.linuxtools.tmf.core.event.TmfEventType;\r
20import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
21import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
c3c5c786
FC
22import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputData;\r
23import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition.InputLine;\r
24\r
25public class CustomTxtEvent extends CustomEvent {\r
26\r
4bf17f4a 27 public CustomTxtEvent(CustomTxtTraceDefinition definition) {\r
28 super(definition);\r
29 fType = new CustomTxtEventType(definition);\r
30 }\r
31\r
c3c5c786
FC
32 public CustomTxtEvent(CustomTxtTraceDefinition definition, TmfEvent other) {\r
33 super(definition, other);\r
34 }\r
35\r
99005796 36 public CustomTxtEvent(CustomTxtTraceDefinition definition, ITmfTrace<?> parentTrace, TmfTimestamp timestamp, String source, TmfEventType type, TmfEventReference reference) {\r
4bf17f4a 37 super(definition, parentTrace, timestamp, source, type, reference);\r
c3c5c786
FC
38 }\r
39\r
c3c5c786 40 public void processGroups(InputLine input, Matcher matcher) {\r
d7fcacc9
FC
41 if (input.columns == null) {\r
42 return;\r
43 }\r
c3c5c786
FC
44 for (int i = 0; i < input.columns.size(); i++) {\r
45 InputData column = input.columns.get(i);\r
46 if (i < matcher.groupCount() && matcher.group(i + 1) != null) {\r
47 String value = matcher.group(i + 1).trim();\r
48 if (value.length() == 0) {\r
49 continue;\r
50 }\r
51 String name = column.name;\r
52 if (column.action == CustomTxtTraceDefinition.ACTION_SET) {\r
53 fData.put(name, value);\r
54 if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
55 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r
56 }\r
57 } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND) {\r
58 String s = fData.get(name);\r
59 if (s != null) {\r
60 fData.put(name, s + value);\r
61 } else {\r
62 fData.put(name, value);\r
63 }\r
64 if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
65 String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
66 if (timeStampInputFormat != null) {\r
67 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + column.format);\r
68 } else {\r
69 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r
70 }\r
71 }\r
72 } else if (column.action == CustomTxtTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
73 String s = fData.get(name);\r
74 if (s != null) {\r
3b38ea61 75 fData.put(name, s + " | " + value); //$NON-NLS-1$\r
c3c5c786
FC
76 } else {\r
77 fData.put(name, value);\r
78 }\r
79 if (name.equals(CustomTxtTraceDefinition.TAG_TIMESTAMP)) {\r
80 String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
81 if (timeStampInputFormat != null) {\r
3b38ea61 82 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + column.format); //$NON-NLS-1$\r
c3c5c786
FC
83 } else {\r
84 fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);\r
85 }\r
86 }\r
87 }\r
88 }\r
89 }\r
90 }\r
91\r
92}\r
This page took 0.057257 seconds and 5 git commands to generate.