tmf: Bug 497038: Custom parser field names conflict with built-in tags
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / parsers / custom / CustomTxtEvent.java
index d555f2028894a4d532a4a0f3258a18659d527aa3..4ea2fd5376bbb355f5e5eb1d95bd733c4de9255b 100644 (file)
@@ -18,6 +18,7 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.Tag;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition.InputData;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition.InputLine;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
@@ -84,7 +85,7 @@ public class CustomTxtEvent extends CustomEvent {
      */
     public void processGroups(InputLine input, Matcher matcher) {
         if (input.eventType != null) {
-            fData.put(CustomTraceDefinition.TAG_EVENT_TYPE, input.eventType);
+            fData.put(Tag.EVENT_TYPE, input.eventType);
         }
         if (input.columns == null) {
             return;
@@ -96,40 +97,40 @@ public class CustomTxtEvent extends CustomEvent {
                 if (value.length() == 0) {
                     continue;
                 }
-                String name = column.name;
+                Object key = (column.tag.equals(Tag.OTHER) ? column.name : column.tag);
                 if (column.action == CustomTraceDefinition.ACTION_SET) {
-                    fData.put(name, value);
-                    if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
-                        fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
+                    fData.put(key, value);
+                    if (key.equals(Tag.TIMESTAMP)) {
+                        fData.put(Key.TIMESTAMP_INPUT_FORMAT, column.format);
                     }
                 } else if (column.action == CustomTraceDefinition.ACTION_APPEND) {
-                    String s = fData.get(name);
+                    String s = fData.get(key);
                     if (s != null) {
-                        fData.put(name, s + value);
+                        fData.put(key, s + value);
                     } else {
-                        fData.put(name, value);
+                        fData.put(key, value);
                     }
-                    if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
-                        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
+                    if (key.equals(Tag.TIMESTAMP)) {
+                        String timeStampInputFormat = fData.get(Key.TIMESTAMP_INPUT_FORMAT);
                         if (timeStampInputFormat != null) {
-                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + column.format);
+                            fData.put(Key.TIMESTAMP_INPUT_FORMAT, timeStampInputFormat + column.format);
                         } else {
-                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
+                            fData.put(Key.TIMESTAMP_INPUT_FORMAT, column.format);
                         }
                     }
                 } else if (column.action == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
-                    String s = fData.get(name);
+                    String s = fData.get(key);
                     if (s != null) {
-                        fData.put(name, s + " | " + value); //$NON-NLS-1$
+                        fData.put(key, s + " | " + value); //$NON-NLS-1$
                     } else {
-                        fData.put(name, value);
+                        fData.put(key, value);
                     }
-                    if (name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
-                        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
+                    if (key.equals(Tag.TIMESTAMP)) {
+                        String timeStampInputFormat = fData.get(Key.TIMESTAMP_INPUT_FORMAT);
                         if (timeStampInputFormat != null) {
-                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, timeStampInputFormat + " | " + column.format); //$NON-NLS-1$
+                            fData.put(Key.TIMESTAMP_INPUT_FORMAT, timeStampInputFormat + " | " + column.format); //$NON-NLS-1$
                         } else {
-                            fData.put(TIMESTAMP_INPUT_FORMAT_KEY, column.format);
+                            fData.put(Key.TIMESTAMP_INPUT_FORMAT, column.format);
                         }
                     }
                 }
This page took 0.024941 seconds and 5 git commands to generate.