Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / parsers / custom / CustomEvent.java
index 6adee3728eb46dddce746f0d5bc0b1b9b7bebe78..01bd80d0dd592d4ccb95efb002e638560b4ee6de 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r
-\r
-import java.text.ParseException;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Arrays;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;\r
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventField;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfEventType;\r
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;\r
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-\r
-public class CustomEvent extends TmfEvent {\r
-\r
-    protected static final String TIMESTAMP_INPUT_FORMAT_KEY = "CE_TS_I_F"; //$NON-NLS-1$\r
-    protected static final String NO_MESSAGE = ""; //$NON-NLS-1$\r
-    public static final byte TIMESTAMP_SCALE = -3;\r
-\r
-    protected CustomTraceDefinition fDefinition;\r
-    protected Map<String, String> fData;\r
-    private TmfEventField[] fColumnData;\r
-\r
-    public CustomEvent(CustomTraceDefinition definition) {\r
-        fDefinition = definition;\r
-        fData = new HashMap<String, String>();\r
-    }\r
-\r
-    public CustomEvent(CustomTraceDefinition definition, TmfEvent other) {\r
-        super(other);\r
-        fDefinition = definition;\r
-        fData = new HashMap<String, String>();\r
-    }\r
-\r
-    public CustomEvent(CustomTraceDefinition definition, ITmfTrace parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {\r
-        super(parentTrace, timestamp, source, type, null, reference);\r
-        fDefinition = definition;\r
-        fData = new HashMap<String, String>();\r
-    }\r
-\r
-    @Override\r
-    public ITmfTimestamp getTimestamp() {\r
-        if (fData != null) {\r
-            processData();\r
-        }\r
-        return super.getTimestamp();\r
-    }\r
-\r
-    public TmfEventField[] extractItemFields() {\r
-        if (fData != null) {\r
-            processData();\r
-        }\r
-        return Arrays.copyOf(fColumnData, fColumnData.length);\r
-    }\r
-\r
-    private void processData() {\r
-        String timeStampString = fData.get(CustomTraceDefinition.TAG_TIMESTAMP);\r
-        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);\r
-        Date date = null;\r
-        if (timeStampInputFormat != null && timeStampString != null) {\r
-            SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampInputFormat);\r
-            try {\r
-                date = dateFormat.parse(timeStampString);\r
-                setTimestamp(new TmfTimestamp(date.getTime(), TIMESTAMP_SCALE));\r
-            } catch (ParseException e) {\r
-                setTimestamp(TmfTimestamp.ZERO);\r
-            }\r
-        } else {\r
-            setTimestamp(TmfTimestamp.ZERO);\r
-        }\r
-\r
-        int i = 0;\r
-        fColumnData = new TmfEventField[fDefinition.outputs.size()];\r
-        for (OutputColumn outputColumn : fDefinition.outputs) {\r
-            String value = fData.get(outputColumn.name);\r
-            if (outputColumn.name.equals(CustomTraceDefinition.TAG_TIMESTAMP) && date != null) {\r
-                SimpleDateFormat dateFormat = new SimpleDateFormat(fDefinition.timeStampOutputFormat);\r
-                fColumnData[i++] = new TmfEventField(outputColumn.name, dateFormat.format(date));\r
-            } else {\r
-                fColumnData[i++] = new TmfEventField(outputColumn.name, (value != null ? value : "")); //$NON-NLS-1$\r
-            }\r
-        }\r
-        CustomEventContent content = (CustomEventContent) getContent();\r
-        content.setFields(fColumnData);\r
-        fData = null;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#hashCode()\r
-     */\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = super.hashCode();\r
-        result = prime * result + ((fDefinition == null) ? 0 : fDefinition.hashCode());\r
-        return result;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see java.lang.Object#equals(java.lang.Object)\r
-     */\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (!super.equals(obj)) {\r
-            return false;\r
-        }\r
-        if (!(obj instanceof CustomEvent)) {\r
-            return false;\r
-        }\r
-        CustomEvent other = (CustomEvent) obj;\r
-        if (fDefinition == null) {\r
-            if (other.fDefinition != null) {\r
-                return false;\r
-            }\r
-        } else if (!fDefinition.equals(other.fDefinition)) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+public class CustomEvent extends TmfEvent {
+
+    protected static final String TIMESTAMP_INPUT_FORMAT_KEY = "CE_TS_I_F"; //$NON-NLS-1$
+    protected static final String NO_MESSAGE = ""; //$NON-NLS-1$
+    public static final byte TIMESTAMP_SCALE = -3;
+
+    protected CustomTraceDefinition fDefinition;
+    protected Map<String, String> fData;
+    private TmfEventField[] fColumnData;
+
+    public CustomEvent(CustomTraceDefinition definition) {
+        fDefinition = definition;
+        fData = new HashMap<String, String>();
+    }
+
+    public CustomEvent(CustomTraceDefinition definition, TmfEvent other) {
+        super(other);
+        fDefinition = definition;
+        fData = new HashMap<String, String>();
+    }
+
+    public CustomEvent(CustomTraceDefinition definition, ITmfTrace parentTrace, ITmfTimestamp timestamp, String source, TmfEventType type, String reference) {
+        super(parentTrace, timestamp, source, type, null, reference);
+        fDefinition = definition;
+        fData = new HashMap<String, String>();
+    }
+
+    @Override
+    public ITmfTimestamp getTimestamp() {
+        if (fData != null) {
+            processData();
+        }
+        return super.getTimestamp();
+    }
+
+    public TmfEventField[] extractItemFields() {
+        if (fData != null) {
+            processData();
+        }
+        return Arrays.copyOf(fColumnData, fColumnData.length);
+    }
+
+    private void processData() {
+        String timeStampString = fData.get(CustomTraceDefinition.TAG_TIMESTAMP);
+        String timeStampInputFormat = fData.get(TIMESTAMP_INPUT_FORMAT_KEY);
+        Date date = null;
+        if (timeStampInputFormat != null && timeStampString != null) {
+            SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampInputFormat);
+            try {
+                date = dateFormat.parse(timeStampString);
+                setTimestamp(new TmfTimestamp(date.getTime(), TIMESTAMP_SCALE));
+            } catch (ParseException e) {
+                setTimestamp(TmfTimestamp.ZERO);
+            }
+        } else {
+            setTimestamp(TmfTimestamp.ZERO);
+        }
+
+        int i = 0;
+        fColumnData = new TmfEventField[fDefinition.outputs.size()];
+        for (OutputColumn outputColumn : fDefinition.outputs) {
+            String value = fData.get(outputColumn.name);
+            if (outputColumn.name.equals(CustomTraceDefinition.TAG_TIMESTAMP) && date != null) {
+                SimpleDateFormat dateFormat = new SimpleDateFormat(fDefinition.timeStampOutputFormat);
+                fColumnData[i++] = new TmfEventField(outputColumn.name, dateFormat.format(date));
+            } else {
+                fColumnData[i++] = new TmfEventField(outputColumn.name, (value != null ? value : "")); //$NON-NLS-1$
+            }
+        }
+        CustomEventContent content = (CustomEventContent) getContent();
+        content.setFields(fColumnData);
+        fData = null;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((fDefinition == null) ? 0 : fDefinition.hashCode());
+        return result;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (!(obj instanceof CustomEvent)) {
+            return false;
+        }
+        CustomEvent other = (CustomEvent) obj;
+        if (fDefinition == null) {
+            if (other.fDefinition != null) {
+                return false;
+            }
+        } else if (!fDefinition.equals(other.fDefinition)) {
+            return false;
+        }
+        return true;
+    }
+
+}
This page took 0.032423 seconds and 5 git commands to generate.