tmf xml: Add a few package-info to tmf.analysis.xml.core.model.*
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Mon, 3 Nov 2014 20:35:06 +0000 (15:35 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Tue, 2 Dec 2014 20:49:57 +0000 (15:49 -0500)
To add NonNullByDefault to classes of the XML model

Change-Id: Ib0e371146aabcc082fcee5d8a61e6b21210abf16
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/35848
Tested-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
20 files changed:
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateAttribute.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/ITmfXmlStateValue.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlCondition.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlEventHandler.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlLocation.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateAttribute.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateChange.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/TmfXmlStateValue.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/package-info.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyModelFactory.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/TmfXmlReadOnlyStateAttribute.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readonly/package-info.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteModelFactory.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateAttribute.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/TmfXmlReadWriteStateValue.java
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/model/readwrite/package-info.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/stateprovider/XmlStateProvider.java
org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/xychart/XmlXYViewer.java
org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java
org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java

index e0c96df5db0d3498df3b56ae5ea0355e7805b82f..a5b584660a579ee3eae011444b592ab89fdda118 100644 (file)
@@ -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);
 }
index c9d4b2a80cf0997360cb8e8544af21c2eb71042d..7c3ad98739f773b13363593622b86fd1c48772d1 100644 (file)
@@ -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;
 
 }
index dc0deaeb784bc5f4fe5657bbf8195135bf279da3..6d33a8bca6507b6b332418f867ac0423db0c8938 100644 (file)
@@ -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<TmfXmlCondition> 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<ITmfXmlStateAttribute> 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);
index b0ff877bfe3bbb31b08af7bdcae12a0dfc2c2e9a..37243d129d6c41d41eda643cec5fc3f6b15402a6 100644 (file)
@@ -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<Element> 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;
         }
index e485d65b96190caedb3d62efa402ccee45f7e766..04991c6d3f0f10e678301f5530ca6ac9f1f88cc9 100644 (file)
@@ -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<Element> 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);
index fc5b102c4afe05d8f864a4d5715f14727306e9c5..54e4a7c7596e9f56c2af362bac6479cdb4e1476c 100644 (file)
@@ -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<ITmfXmlStateAttribute> fQueryList = new LinkedList<>();
@@ -100,6 +100,9 @@ public abstract class TmfXmlStateAttribute implements ITmfXmlStateAttribute {
         case TmfXmlStrings.TYPE_QUERY:
             List<Element> 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<TmfCpuAspect> cpuAspects = TmfTraceUtils.getEventAspectsOfClass(
                             event.getTrace(), TmfCpuAspect.class);
index dad5ad2d717863b7fef06b69f970ec5c1542ca70..52e317573ac22d2a6da06cba067574aea4d9de0f 100644 (file)
@@ -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<ITmfXmlStateAttribute> attributes = new ArrayList<>();
             for (Element element : childElements) {
                 if (!element.getNodeName().equals(TmfXmlStrings.STATE_ATTRIBUTE)) {
index eb7c585c571b734e101e5475052f9fb01600f4ea..db621edd533fa8a4f46a55f6367f2762b35b603b 100644 (file)
@@ -51,7 +51,7 @@ public abstract class TmfXmlStateValue implements ITmfXmlStateValue {
     /* Path in the State System */
     private final List<ITmfXmlStateAttribute> 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<ITmfXmlStateAttribute> attributes, String eventField) {
+    protected TmfXmlStateValue(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer container, List<ITmfXmlStateAttribute> 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<TmfCpuAspect> 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 (file)
index 0000000..398e7bf
--- /dev/null
@@ -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;
index c844edae72cf86c34c19b6e52e7d379fac8f1f8f..ef1f9c4351bd31442c3e66e949b62459815434c5 100644 (file)
@@ -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) {
index 5029cb69de6dbc3818053b26b3d55aa69bd2a064..4a580b75e154d9298a5b60438ef8696fd108b038 100644 (file)
@@ -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 (file)
index 0000000..4452137
--- /dev/null
@@ -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;
index 743d039e5231419bc2c9b630de071f4bf0e44b67..84acc894059ade414e745205aa2debb856857884 100644 (file)
@@ -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) {
index c299ba4a90910ca55a897c71885ecf0d3c7aaefa..1841fd3fd99d8f3205ff882229a7344ab5edb187 100644 (file)
@@ -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);
     }
 
 }
index d0da302723909b585ffc08ec4aa251695d6f6571..50a1e2a5ce2b709128c4c6d026ba1e838c2a18c0 100644 (file)
@@ -76,12 +76,12 @@ public class TmfXmlReadWriteStateValue extends TmfXmlStateValue {
         this(modelFactory, node, container, new ArrayList<ITmfXmlStateAttribute>(), eventField);
     }
 
-    private TmfXmlReadWriteStateValue(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer container, List<ITmfXmlStateAttribute> attributes, String eventField) {
+    private TmfXmlReadWriteStateValue(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer container, List<ITmfXmlStateAttribute> 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<Element> children = XmlUtils.getChildElements(node);
             List<ITmfXmlStateAttribute> 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 (file)
index 0000000..a5ea3e2
--- /dev/null
@@ -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;
index 22ebded919c0fba87dc3a342c6b0ce9d12d72ff1..ca31f205f63e87faf12913aed9fa1690da3848c5 100644 (file)
@@ -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<Element> childElements = XmlUtils.getChildElements(doc, TmfXmlStrings.LOCATION);
         Set<TmfXmlLocation> 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);
         }
index b102158df0189f56b64bdda5e01e19c1f43335a0..1b6d42d19322173eba81386acab8cea1d954ee7c 100644 (file)
@@ -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<Element> 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);
         }
 
index 327a07d8819ace83faa1a24d209f79379eeae882..7b9901dba4bb00ee7c2bf3cb19fdaa3fc8646ee4 100644 (file)
@@ -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);
index c11c40731fab1b5aea36a877ddd7e033b6d33637..7305f35183eb711f5ee68264b765a20e7d41079d 100644 (file)
@@ -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
This page took 0.042318 seconds and 5 git commands to generate.