From 12685851a54fed76b2af25335f748bfd89e0e8bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Mon, 3 Nov 2014 15:35:06 -0500 Subject: [PATCH] tmf xml: Add a few package-info to tmf.analysis.xml.core.model.* MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit To add NonNullByDefault to classes of the XML model Change-Id: Ib0e371146aabcc082fcee5d8a61e6b21210abf16 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/35848 Tested-by: Hudson CI Reviewed-by: Matthew Khouzam --- .../xml/core/model/ITmfXmlStateAttribute.java | 3 +- .../xml/core/model/ITmfXmlStateValue.java | 5 +- .../xml/core/model/TmfXmlCondition.java | 34 ++++++++---- .../xml/core/model/TmfXmlEventHandler.java | 20 ++++--- .../xml/core/model/TmfXmlLocation.java | 12 ++++- .../xml/core/model/TmfXmlStateAttribute.java | 16 ++++-- .../xml/core/model/TmfXmlStateChange.java | 13 +++-- .../xml/core/model/TmfXmlStateValue.java | 22 +++++--- .../analysis/xml/core/model/package-info.java | 13 +++++ .../readonly/TmfXmlReadOnlyModelFactory.java | 5 +- .../TmfXmlReadOnlyStateAttribute.java | 13 ++++- .../xml/core/model/readonly/package-info.java | 13 +++++ .../TmfXmlReadWriteModelFactory.java | 5 +- .../TmfXmlReadWriteStateAttribute.java | 15 ++++-- .../readwrite/TmfXmlReadWriteStateValue.java | 52 +++++++++++++++---- .../core/model/readwrite/package-info.java | 13 +++++ .../core/stateprovider/XmlStateProvider.java | 17 +++--- .../xml/ui/views/xychart/XmlXYViewer.java | 6 +++ .../xml/ui/views/timegraph/XmlEntry.java | 3 ++ .../ui/views/timegraph/XmlTimeGraphView.java | 2 +- 20 files changed, 217 insertions(+), 65 deletions(-) create mode 100644 org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/package-info.java create mode 100644 org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/package-info.java create mode 100644 org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/package-info.java diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateAttribute.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateAttribute.java index e0c96df5db..a5b584660a 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateAttribute.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateAttribute.java @@ -12,6 +12,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.IXmlStateSystemContainer; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; @@ -52,5 +53,5 @@ public interface ITmfXmlStateAttribute { * @return the quark described by attribute or * {@link IXmlStateSystemContainer#ERROR_QUARK} if quark cannot be found */ - int getAttributeQuark(ITmfEvent event, int startQuark); + int getAttributeQuark(@Nullable ITmfEvent event, int startQuark); } diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateValue.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateValue.java index c9d4b2a80c..7c3ad98739 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateValue.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateValue.java @@ -14,7 +14,6 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model; import java.util.List; -import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; @@ -51,7 +50,7 @@ public interface ITmfXmlStateValue { * The current event * @return the value of the event field */ - ITmfStateValue getEventFieldValue(@NonNull ITmfEvent event); + ITmfStateValue getEventFieldValue(ITmfEvent event); /** * Get the list of state attributes, the path to the state value @@ -73,6 +72,6 @@ public interface ITmfXmlStateValue { * @throws StateValueTypeException * Pass through the exception it received */ - void handleEvent(@NonNull ITmfEvent event) throws AttributeNotFoundException, StateValueTypeException, TimeRangeException; + void handleEvent(ITmfEvent event) throws AttributeNotFoundException, StateValueTypeException, TimeRangeException; } diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java index dc0deaeb78..6d33a8bca6 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java @@ -16,7 +16,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model; import java.util.ArrayList; import java.util.List; -import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; @@ -47,7 +47,7 @@ import org.w3c.dom.Element; public class TmfXmlCondition { private final List fConditions = new ArrayList<>(); - private final ITmfXmlStateValue fStateValue; + private final @Nullable ITmfXmlStateValue fStateValue; private final LogicalOperator fOperator; private final IXmlStateSystemContainer fContainer; private final ConditionOperator fConditionOperator; @@ -132,13 +132,20 @@ public class TmfXmlCondition { } /* The last element is a state value node */ Element stateValueElement = childElements.remove(childElements.size() - 1); + if (stateValueElement == null) { + throw new IllegalStateException(); + } /* * A state value is either preceded by an eventField or a number of * state attributes */ if (childElements.size() == 1 && childElements.get(0).getNodeName().equals(TmfXmlStrings.ELEMENT_FIELD)) { - fStateValue = modelFactory.createStateValue(stateValueElement, fContainer, childElements.get(0).getAttribute(TmfXmlStrings.NAME)); + String attribute = childElements.get(0).getAttribute(TmfXmlStrings.NAME); + if (attribute == null) { + throw new IllegalArgumentException(); + } + fStateValue = modelFactory.createStateValue(stateValueElement, fContainer, attribute); } else { List attributes = new ArrayList<>(); for (Element element : childElements) { @@ -155,13 +162,20 @@ public class TmfXmlCondition { fOperator = LogicalOperator.NOT; fStateValue = null; fConditionOperator = ConditionOperator.NONE; - fConditions.add(modelFactory.createCondition(childElements.get(0), fContainer)); + Element element = childElements.get(0); + if (element == null) { + throw new IllegalArgumentException(); + } + fConditions.add(modelFactory.createCondition(element, fContainer)); break; case TmfXmlStrings.AND: fOperator = LogicalOperator.AND; fStateValue = null; fConditionOperator = ConditionOperator.NONE; for (Element condition : childElements) { + if (condition == null) { + continue; + } fConditions.add(modelFactory.createCondition(condition, fContainer)); } break; @@ -170,6 +184,9 @@ public class TmfXmlCondition { fStateValue = null; fConditionOperator = ConditionOperator.NONE; for (Element condition : childElements) { + if (condition == null) { + continue; + } fConditions.add(modelFactory.createCondition(condition, fContainer)); } break; @@ -187,7 +204,7 @@ public class TmfXmlCondition { * @throws AttributeNotFoundException * The state attribute was not found */ - public boolean testForEvent(@NonNull ITmfEvent event) throws AttributeNotFoundException { + public boolean testForEvent(ITmfEvent event) throws AttributeNotFoundException { ITmfStateSystem ss = fContainer.getStateSystem(); /* * The condition is either the equality check of a state value or a @@ -218,6 +235,9 @@ public class TmfXmlCondition { */ ITmfStateValue valueState = (quark != IXmlStateSystemContainer.ROOT_QUARK) ? ss.queryOngoingState(quark) : filter.getEventFieldValue(event); + if (valueState == null) { + throw new IllegalStateException(); + } return compare(valueState, valueXML, fConditionOperator); @@ -269,10 +289,6 @@ public class TmfXmlCondition { * @return the boolean result of the comparison */ public boolean compare(ITmfStateValue source, ITmfStateValue dest, ConditionOperator comparisonOperator) { - if (source == null || dest == null) { - throw new IllegalArgumentException(); - } - switch (comparisonOperator) { case EQ: return (source.compareTo(dest) == 0); diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java index b0ff877bfe..37243d129d 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java @@ -15,16 +15,15 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model; import java.util.ArrayList; import java.util.List; -import org.eclipse.jdt.annotation.NonNull; import org.eclipse.tracecompass.internal.tmf.analysis.xml.core.Activator; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.IXmlStateSystemContainer; +import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils; import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.w3c.dom.Element; -import org.w3c.dom.NodeList; /** * This Class implements an EventHandler in the XML-defined state system @@ -62,12 +61,19 @@ public class TmfXmlEventHandler { */ public TmfXmlEventHandler(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer parent) { fParent = parent; - fName = node.getAttribute(TmfXmlStrings.HANDLER_EVENT_NAME); + String name = node.getAttribute(TmfXmlStrings.HANDLER_EVENT_NAME); + if (name == null) { + throw new IllegalArgumentException(); + } + fName = name; - NodeList nodesChanges = node.getElementsByTagName(TmfXmlStrings.STATE_CHANGE); + List childElements = XmlUtils.getChildElements(node, TmfXmlStrings.STATE_CHANGE); /* load state changes */ - for (int i = 0; i < nodesChanges.getLength(); i++) { - TmfXmlStateChange stateChange = modelFactory.createStateChange((Element) nodesChanges.item(i), fParent); + for (Element childElem : childElements) { + if (childElem == null) { + continue; + } + TmfXmlStateChange stateChange = modelFactory.createStateChange(childElem, fParent); fStateChangeList.add(stateChange); } } @@ -94,7 +100,7 @@ public class TmfXmlEventHandler { * @param event * The trace event to handle */ - public void handleEvent(@NonNull ITmfEvent event) { + public void handleEvent(ITmfEvent event) { if (!appliesToEvent(event)) { return; } diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java index e485d65b96..04991c6d3f 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model; import java.util.LinkedList; import java.util.List; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.IXmlStateSystemContainer; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils; import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings; @@ -56,11 +57,18 @@ public class TmfXmlLocation { * The state system container this location belongs to */ public TmfXmlLocation(ITmfXmlModelFactory modelFactory, Element location, IXmlStateSystemContainer container) { - fId = location.getAttribute(TmfXmlStrings.ID); + String id = location.getAttribute(TmfXmlStrings.ID); + if (id == null) { + throw new IllegalArgumentException(); + } + fId = id; fContainer = container; List childElements = XmlUtils.getChildElements(location); for (Element attribute : childElements) { + if (attribute == null) { + continue; + } ITmfXmlStateAttribute xAttribute = modelFactory.createStateAttribute(attribute, fContainer); fPath.add(xAttribute); } @@ -86,7 +94,7 @@ public class TmfXmlLocation { * the attribute tree * @return The quark at the leaf of the path */ - public int getLocationQuark(ITmfEvent event, int startQuark) { + public int getLocationQuark(@Nullable ITmfEvent event, int startQuark) { int quark = startQuark; for (ITmfXmlStateAttribute attrib : fPath) { quark = attrib.getAttributeQuark(event, quark); diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java index fc5b102c4a..54e4a7c759 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java @@ -64,7 +64,7 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute { private final StateAttributeType fType; /** Attribute's name */ - private final String fName; + private final @Nullable String fName; /** List of attributes for a query */ private final List fQueryList = new LinkedList<>(); @@ -100,6 +100,9 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute { case TmfXmlStrings.TYPE_QUERY: List childElements = XmlUtils.getChildElements(attribute); for (Element subAttributeNode : childElements) { + if (subAttributeNode == null) { + continue; + } ITmfXmlStateAttribute subAttribute = modelFactory.createStateAttribute(subAttributeNode, fContainer); fQueryList.add(subAttribute); } @@ -180,7 +183,7 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute { * * @return The state system associated with this state attribute */ - protected ITmfStateSystem getStateSystem() { + protected @Nullable ITmfStateSystem getStateSystem() { return fContainer.getStateSystem(); } @@ -204,6 +207,9 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute { @Override public int getAttributeQuark(@Nullable ITmfEvent event, int startQuark) { ITmfStateSystem ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } try { switch (fType) { @@ -223,7 +229,11 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute { return quark; } /* special case if field is CPU which is not in the field */ - if (fName.equals(TmfXmlStrings.CPU)) { + String name = fName; + if (name == null) { + throw new IllegalStateException(); + } + if (name.equals(TmfXmlStrings.CPU)) { /* See if the event advertises a CPU aspect */ Iterable cpuAspects = TmfTraceUtils.getEventAspectsOfClass( event.getTrace(), TmfCpuAspect.class); diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java index dad5ad2d71..52e317573a 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; @@ -106,7 +107,7 @@ public class TmfXmlStateChange { * @throws StateValueTypeException * Pass through the exception it received */ - public void handleEvent(@NonNull ITmfEvent event) throws AttributeNotFoundException, StateValueTypeException, TimeRangeException { + public void handleEvent(ITmfEvent event) throws AttributeNotFoundException, StateValueTypeException, TimeRangeException { fChange.handleEvent(event); } @@ -117,7 +118,7 @@ public class TmfXmlStateChange { /* Interface for both private classes to handle the event */ private interface IXmlStateChange { - void handleEvent(@NonNull ITmfEvent event) throws AttributeNotFoundException, StateValueTypeException, TimeRangeException; + void handleEvent(ITmfEvent event) throws AttributeNotFoundException, StateValueTypeException, TimeRangeException; } /** @@ -126,13 +127,16 @@ public class TmfXmlStateChange { private class XmlConditionalChange implements IXmlStateChange { private final TmfXmlCondition fCondition; private final TmfXmlStateChange fThenChange; - private final TmfXmlStateChange fElseChange; + private final @Nullable TmfXmlStateChange fElseChange; public XmlConditionalChange(ITmfXmlModelFactory modelFactory, Element statechange) { /* * The if node exists, it has been verified before calling this */ Node ifNode = statechange.getElementsByTagName(TmfXmlStrings.IF).item(0); + if (ifNode == null) { + throw new IllegalArgumentException(); + } fCondition = modelFactory.createCondition((Element) ifNode, fContainer); Node thenNode = statechange.getElementsByTagName(TmfXmlStrings.THEN).item(0); @@ -190,6 +194,9 @@ public class TmfXmlStateChange { * to reach to value to set */ Element stateValueElement = childElements.remove(childElements.size() - 1); + if (stateValueElement == null) { + throw new IllegalStateException(); + } List attributes = new ArrayList<>(); for (Element element : childElements) { if (!element.getNodeName().equals(TmfXmlStrings.STATE_ATTRIBUTE)) { diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateValue.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateValue.java index eb7c585c57..db621edd53 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateValue.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateValue.java @@ -51,7 +51,7 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue { /* Path in the State System */ private final List fPath; /* Event field to match with this state value */ - private final String fEventField; + private final @Nullable String fEventField; /* Whether this state value is an increment of the previous value */ private final boolean fIncrement; @@ -110,7 +110,7 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue { * @param attributes * The attributes representing the path to this value */ - protected TmfXmlStateValue(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer container, List attributes, String eventField) { + protected TmfXmlStateValue(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer container, List attributes, @Nullable String eventField) { fPath = attributes; fContainer = container; fEventField = eventField; @@ -146,7 +146,8 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue { /* * Stack Actions : allow to define a stack with PUSH/POP/PEEK methods */ - String stack = node.getAttribute(TmfXmlStrings.ATTRIBUTE_STACK); + @SuppressWarnings("null") + @NonNull String stack = node.getAttribute(TmfXmlStrings.ATTRIBUTE_STACK); fStackType = ValueTypeStack.getTypeFromString(stack); } @@ -177,7 +178,7 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue { * * @return The state system associated with the state system container */ - protected ITmfStateSystem getStateSystem() { + protected @Nullable ITmfStateSystem getStateSystem() { return fContainer.getStateSystem(); } @@ -236,7 +237,11 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue { */ @Override public ITmfStateValue getEventFieldValue(@NonNull ITmfEvent event) { - return getEventFieldValue(event, fEventField); + String eventField = fEventField; + if (eventField == null) { + throw new IllegalStateException(); + } + return getEventFieldValue(event, eventField); } /** @@ -248,13 +253,14 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue { * The name of the field of which to get the value * @return The value of the event field */ - protected ITmfStateValue getEventFieldValue(@NonNull ITmfEvent event, String fieldName) { + protected ITmfStateValue getEventFieldValue(ITmfEvent event, String fieldName) { ITmfStateValue value = TmfStateValue.nullValue(); final ITmfEventField content = event.getContent(); - /* Exception for "CPU", returns the source CPU of this event */ + /* Exception for "CPU", returns the source of this event */ + /* FIXME : Nameclash if a eventfield have "cpu" for name. */ if (fieldName.equals(TmfXmlStrings.CPU)) { /* See if the event advertises a CPU aspect */ Iterable cpuAspects = TmfTraceUtils.getEventAspectsOfClass( @@ -442,7 +448,7 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue { * @throws AttributeNotFoundException * Pass through the exception it received */ - public void handleEvent(@NonNull ITmfEvent event, int quark, long timestamp) throws StateValueTypeException, TimeRangeException, AttributeNotFoundException { + public void handleEvent(ITmfEvent event, int quark, long timestamp) throws StateValueTypeException, TimeRangeException, AttributeNotFoundException { if (fIncrement) { incrementValue(event, quark, timestamp); } else { diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/package-info.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/package-info.java new file mode 100644 index 0000000000..398e7bf8fe --- /dev/null +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/package-info.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 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: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault package org.eclipse.tracecompass.tmf.analysis.xml.core.model; diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyModelFactory.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyModelFactory.java index c844edae72..ef1f9c4351 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyModelFactory.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyModelFactory.java @@ -14,7 +14,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly; import java.util.List; -import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlModelFactory; import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlStateAttribute; import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlStateValue; @@ -33,14 +33,13 @@ import org.w3c.dom.Element; */ public class TmfXmlReadOnlyModelFactory implements ITmfXmlModelFactory { - private static ITmfXmlModelFactory fInstance = null; + private static @Nullable ITmfXmlModelFactory fInstance = null; /** * Get the instance of this model creator * * @return The {@link TmfXmlReadWriteModelFactory} instance */ - @NonNull public static synchronized ITmfXmlModelFactory getInstance() { ITmfXmlModelFactory instance = fInstance; if (instance == null) { diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateAttribute.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateAttribute.java index 5029cb69de..4a580b75e1 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateAttribute.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateAttribute.java @@ -12,6 +12,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly; +import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlStateAttribute; import org.eclipse.tracecompass.tmf.analysis.xml.core.module.IXmlStateSystemContainer; @@ -44,12 +45,20 @@ public class TmfXmlReadOnlyStateAttribute extends TmfXmlStateAttribute { @Override protected int getQuarkAbsoluteAndAdd(String... path) throws AttributeNotFoundException { - return getStateSystem().getQuarkAbsolute(path); + ITmfStateSystem ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } + return ss.getQuarkAbsolute(path); } @Override protected int getQuarkRelativeAndAdd(int startNodeQuark, String... path) throws AttributeNotFoundException { - return getStateSystem().getQuarkRelative(startNodeQuark, path); + ITmfStateSystem ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } + return ss.getQuarkRelative(startNodeQuark, path); } } diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/package-info.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/package-info.java new file mode 100644 index 0000000000..44521379ad --- /dev/null +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/package-info.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 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: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readonly; diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteModelFactory.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteModelFactory.java index 743d039e52..84acc89405 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteModelFactory.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteModelFactory.java @@ -14,7 +14,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readwrite; import java.util.List; -import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlModelFactory; import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlStateAttribute; import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlStateValue; @@ -32,14 +32,13 @@ import org.w3c.dom.Element; */ public class TmfXmlReadWriteModelFactory implements ITmfXmlModelFactory { - private static ITmfXmlModelFactory fInstance = null; + private static @Nullable ITmfXmlModelFactory fInstance = null; /** * Get the instance of this model creator * * @return The {@link TmfXmlReadWriteModelFactory} instance */ - @NonNull public static synchronized ITmfXmlModelFactory getInstance() { ITmfXmlModelFactory instance = fInstance; if (instance == null) { diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateAttribute.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateAttribute.java index c299ba4a90..1841fd3fd9 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateAttribute.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateAttribute.java @@ -12,6 +12,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readwrite; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder; import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; import org.eclipse.tracecompass.tmf.analysis.xml.core.model.TmfXmlStateAttribute; @@ -44,18 +45,26 @@ public class TmfXmlReadWriteStateAttribute extends TmfXmlStateAttribute { } @Override - protected ITmfStateSystemBuilder getStateSystem() { + protected @Nullable ITmfStateSystemBuilder getStateSystem() { return (ITmfStateSystemBuilder) super.getStateSystem(); } @Override protected int getQuarkAbsoluteAndAdd(String... path) throws AttributeNotFoundException { - return getStateSystem().getQuarkAbsoluteAndAdd(path); + ITmfStateSystemBuilder ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } + return ss.getQuarkAbsoluteAndAdd(path); } @Override protected int getQuarkRelativeAndAdd(int startNodeQuark, String... path) throws AttributeNotFoundException { - return getStateSystem().getQuarkRelativeAndAdd(startNodeQuark, path); + ITmfStateSystemBuilder ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } + return ss.getQuarkRelativeAndAdd(startNodeQuark, path); } } diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java index d0da302723..50a1e2a5ce 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java @@ -76,12 +76,12 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { this(modelFactory, node, container, new ArrayList(), eventField); } - private TmfXmlReadWriteStateValue(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer container, List attributes, String eventField) { + private TmfXmlReadWriteStateValue(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer container, List attributes, @Nullable String eventField) { super(modelFactory, node, container, attributes, eventField); } @Override - protected ITmfStateSystemBuilder getStateSystem() { + protected @Nullable ITmfStateSystemBuilder getStateSystem() { return (ITmfStateSystemBuilder) super.getStateSystem(); } @@ -91,6 +91,9 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { /* Process the XML Element state value */ String type = node.getAttribute(TmfXmlStrings.TYPE); String value = getSsContainer().getAttributeValue(node.getAttribute(TmfXmlStrings.VALUE)); + if (value == null) { + throw new IllegalStateException(); + } switch (type) { case TmfXmlStrings.TYPE_INT: { @@ -134,6 +137,9 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { List children = XmlUtils.getChildElements(node); List childAttributes = new ArrayList<>(); for (Element child : children) { + if (child == null) { + continue; + } ITmfXmlStateAttribute queryAttribute = modelFactory.createStateAttribute(child, getSsContainer()); childAttributes.add(queryAttribute); } @@ -167,24 +173,32 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { @Override protected void processValue(int quark, long timestamp, ITmfStateValue value) throws AttributeNotFoundException, TimeRangeException, StateValueTypeException { + ITmfStateSystemBuilder ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } switch (getStackType()) { case POP: - getStateSystem().popAttribute(timestamp, quark); + ss.popAttribute(timestamp, quark); break; case PUSH: - getStateSystem().pushAttribute(timestamp, value, quark); + ss.pushAttribute(timestamp, value, quark); break; case NULL: case PEEK: default: - getStateSystem().modifyAttribute(timestamp, value, quark); + ss.modifyAttribute(timestamp, value, quark); break; } } @Override protected void incrementValue(ITmfEvent event, int quark, long timestamp) throws StateValueTypeException, TimeRangeException, AttributeNotFoundException { - getStateSystem().incrementAttribute(timestamp, quark); + ITmfStateSystemBuilder ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } + ss.incrementAttribute(timestamp, quark); } } @@ -223,13 +237,16 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { } @Override - public ITmfStateValue getValue(ITmfEvent event) { + public ITmfStateValue getValue(@Nullable ITmfEvent event) { return fValue; } @Override public void incrementValue(ITmfEvent event, int quark, long timestamp) throws StateValueTypeException, TimeRangeException, AttributeNotFoundException { ITmfStateSystem ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } ITmfStateValue value = incrementByType(quark, timestamp, ss, fValue); if (value != null) { processValue(quark, timestamp, value); @@ -250,7 +267,7 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { } @Override - public ITmfStateValue getValue(ITmfEvent event) { + public ITmfStateValue getValue(@Nullable ITmfEvent event) { if (event == null) { Activator.logWarning("XML State value: requested an event field, but event is null"); //$NON-NLS-1$ return TmfStateValue.nullValue(); @@ -261,6 +278,9 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { @Override public void incrementValue(ITmfEvent event, int quark, long timestamp) throws StateValueTypeException, TimeRangeException, AttributeNotFoundException { ITmfStateSystem ss = getSsContainer().getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } ITmfStateValue incrementValue = getValue(event); ITmfStateValue value = incrementByType(quark, timestamp, ss, incrementValue); if (value != null) { @@ -275,7 +295,7 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { private class TmfXmlStateValueEventName extends TmfXmlStateValueTypeReadWrite { @Override - public ITmfStateValue getValue(ITmfEvent event) { + public ITmfStateValue getValue(@Nullable ITmfEvent event) { if (event == null) { Activator.logWarning("XML State value: request event name, but event is null"); //$NON-NLS-1$ return TmfStateValue.nullValue(); @@ -289,7 +309,7 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { private class TmfXmlStateValueDelete extends TmfXmlStateValueTypeReadWrite { @Override - public ITmfStateValue getValue(ITmfEvent event) throws AttributeNotFoundException { + public ITmfStateValue getValue(@Nullable ITmfEvent event) throws AttributeNotFoundException { return TmfStateValue.nullValue(); } @@ -315,11 +335,14 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { } @Override - public ITmfStateValue getValue(ITmfEvent event) throws AttributeNotFoundException { + public ITmfStateValue getValue(@Nullable ITmfEvent event) throws AttributeNotFoundException { /* Query the state system for the value */ ITmfStateValue value = TmfStateValue.nullValue(); int quarkQuery = IXmlStateSystemContainer.ROOT_QUARK; ITmfStateSystem ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } for (ITmfXmlStateAttribute attribute : fQueryValue) { quarkQuery = attribute.getAttributeQuark(event, quarkQuery); @@ -334,6 +357,9 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { */ if (quarkQuery != IXmlStateSystemContainer.ERROR_QUARK) { value = ss.queryOngoingState(quarkQuery); + if (value == null) { + throw new IllegalStateException(); + } } return value; } @@ -341,6 +367,10 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue { @Override public void incrementValue(ITmfEvent event, int quark, long timestamp) throws StateValueTypeException, TimeRangeException, AttributeNotFoundException { ITmfStateSystem ss = getStateSystem(); + if (ss == null) { + throw new IllegalStateException("The state system hasn't been initialized yet"); //$NON-NLS-1$ + } + ITmfStateValue incrementValue = getValue(event); ITmfStateValue value = incrementByType(quark, timestamp, ss, incrementValue); if (value != null) { diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/package-info.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/package-info.java new file mode 100644 index 0000000000..a5ea3e2239 --- /dev/null +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/package-info.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2014 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: + * Ericsson - Initial API and implementation + *******************************************************************************/ + +@org.eclipse.jdt.annotation.NonNullByDefault package org.eclipse.tracecompass.tmf.analysis.xml.core.model.readwrite; diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java index 22ebded919..ca31f205f6 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java @@ -15,6 +15,7 @@ package org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -87,19 +88,23 @@ public class XmlStateProvider extends AbstractTmfStateProvider implements IXmlSt } /* parser for the locations */ - NodeList locationNodes = doc.getElementsByTagName(TmfXmlStrings.LOCATION); + List childElements = XmlUtils.getChildElements(doc, TmfXmlStrings.LOCATION); Set locations = new HashSet<>(); - for (int i = 0; i < locationNodes.getLength(); i++) { - Element element = (Element) locationNodes.item(i); + for (Element element : childElements) { + if (element == null) { + continue; + } TmfXmlLocation location = modelFactory.createLocation(element, this); locations.add(location); } fLocations = Collections.unmodifiableSet(locations); /* parser for the event handlers */ - NodeList nodes = doc.getElementsByTagName(TmfXmlStrings.EVENT_HANDLER); - for (int i = 0; i < nodes.getLength(); i++) { - Element element = (Element) nodes.item(i); + childElements = XmlUtils.getChildElements(doc, TmfXmlStrings.EVENT_HANDLER); + for (Element element : childElements) { + if (element == null) { + continue; + } TmfXmlEventHandler handler = modelFactory.createEventHandler(element, this); fEventHandlers.add(handler); } diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java index b102158df0..1b6d42d193 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java @@ -396,12 +396,18 @@ public class XmlXYViewer extends TmfCommonXLineChartViewer { return; } Element displayElement = displayElements.get(0); + if (displayElement == null) { + throw new IllegalStateException(); + } fDisplay = fFactory.createStateAttribute(displayElement, entry); /* Get the series name element to use */ List seriesNameElements = XmlUtils.getChildElements(entryElement, TmfXmlUiStrings.NAME_ELEMENT); if (!seriesNameElements.isEmpty()) { Element seriesNameElement = seriesNameElements.get(0); + if (seriesNameElement == null) { + throw new IllegalStateException(); + } fSeriesName = fFactory.createStateAttribute(seriesNameElement, entry); } diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java index 327a07d881..7b9901dba4 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java @@ -150,6 +150,9 @@ public class XmlEntry extends TimeGraphEntry implements IXmlStateSystemContainer /** Return the state value of the first interval with a non-null value */ private String getFirstValue(Element stateAttribute) { + if (stateAttribute == null) { + throw new IllegalArgumentException(); + } ITmfXmlModelFactory factory = TmfXmlReadOnlyModelFactory.getInstance(); ITmfXmlStateAttribute display = factory.createStateAttribute(stateAttribute, this); diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java index c11c40731f..7305f35183 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java @@ -377,7 +377,7 @@ public class XmlTimeGraphView extends AbstractTimeGraphView { } private XmlEntry processEntry(@NonNull Element entryElement, @NonNull Element displayEl, - XmlEntry parentEntry, int quark, ITmfStateSystem ss) { + @NonNull XmlEntry parentEntry, int quark, ITmfStateSystem ss) { /* * Get the start time and end time of this entry from the display * attribute -- 2.34.1