From 7a0b1e3c9bb9d6d8b4d5753202f0c0b6753f60ea Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Thu, 2 Jul 2015 16:18:29 -0400 Subject: [PATCH] tmf: Make custom trace output column name @NonNull Change-Id: Ibe9600a9b80833a860c361320d5d755d148e2711 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/51302 Reviewed-by: Hudson CI Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam Reviewed-by: Alexandre Montplaisir Tested-by: Alexandre Montplaisir --- .../tmf/core/parsers/custom/CustomEventAspects.java | 6 ++---- .../core/parsers/custom/CustomTraceDefinition.java | 11 +++++++---- .../core/parsers/custom/CustomTxtTraceDefinition.java | 4 +++- .../core/parsers/custom/CustomXmlTraceDefinition.java | 4 +++- .../wizards/CustomTxtParserOutputWizardPage.java | 6 ++++-- .../wizards/CustomXmlParserOutputWizardPage.java | 6 ++++-- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java index 060532013c..26a79159ff 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 Ericsson + * Copyright (c) 2010, 2015 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -94,9 +94,7 @@ public class CustomEventAspects { List outputs = definition.outputs; for (int i = 0; i < outputs.size(); i++) { String name = outputs.get(i).name; - if (name != null) { - builder.add(new CustomEventFieldAspect(name, i)); - } + builder.add(new CustomEventFieldAspect(name, i)); } return checkNotNull(builder.build()); } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java index 11f7a6ca57..93ef98ec64 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTraceDefinition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 Ericsson + * Copyright (c) 2010, 2015 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -16,6 +16,7 @@ import java.io.ByteArrayInputStream; import java.text.SimpleDateFormat; import java.util.List; +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.xml.sax.EntityResolver; import org.xml.sax.ErrorHandler; @@ -66,19 +67,21 @@ public abstract class CustomTraceDefinition { public static class OutputColumn { /** Name of this column */ - public String name; + public @NonNull String name; /** * Default constructor (empty) */ - public OutputColumn() {} + public OutputColumn() { + this(""); //$NON-NLS-1$ + } /** * Constructor * * @param name Name of this output column */ - public OutputColumn(String name) { + public OutputColumn(@NonNull String name) { this.name = name; } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java index 8bbfcb6980..f2fa3e019c 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTraceDefinition.java @@ -13,6 +13,8 @@ package org.eclipse.tracecompass.tmf.core.parsers.custom; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -809,7 +811,7 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition { } else if (nodeName.equals(OUTPUT_COLUMN_ELEMENT)) { Element outputColumnElement = (Element) node; OutputColumn outputColumn = new OutputColumn(); - outputColumn.name = outputColumnElement.getAttribute(NAME_ATTRIBUTE); + outputColumn.name = checkNotNull(outputColumnElement.getAttribute(NAME_ATTRIBUTE)); def.outputs.add(outputColumn); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java index 19263f4ffd..47cc6faa55 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTraceDefinition.java @@ -13,6 +13,8 @@ package org.eclipse.tracecompass.tmf.core.parsers.custom; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; @@ -520,7 +522,7 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition { } else if (nodeName.equals(OUTPUT_COLUMN_ELEMENT)) { Element outputColumnElement = (Element) node; OutputColumn outputColumn = new OutputColumn(); - outputColumn.name = outputColumnElement.getAttribute(NAME_ATTRIBUTE); + outputColumn.name = checkNotNull(outputColumnElement.getAttribute(NAME_ATTRIBUTE)); def.outputs.add(outputColumn); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java index aea1ac827b..2a637b9561 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 Ericsson + * Copyright (c) 2010, 2015 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -12,6 +12,8 @@ package org.eclipse.tracecompass.internal.tmf.ui.parsers.wizards; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -262,7 +264,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage { final Output output = outputs.get(i); if (output.enabledButton.getSelection()) { final OutputColumn column = new OutputColumn(); - column.name = output.nameLabel.getText(); + column.name = checkNotNull(output.nameLabel.getText()); outputColumns.add(column); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java index a74ab58d75..bcf746899f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 Ericsson + * Copyright (c) 2010, 2015 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -12,6 +12,8 @@ package org.eclipse.tracecompass.internal.tmf.ui.parsers.wizards; +import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -263,7 +265,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage { final Output output = outputs.get(i); if (output.enabledButton.getSelection()) { final OutputColumn column = new OutputColumn(); - column.name = output.nameLabel.getText(); + column.name = checkNotNull(output.nameLabel.getText()); outputColumns.add(column); } } -- 2.34.1