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;
* @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);
}
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;
* 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
* @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;
}
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;
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;
}
/* 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) {
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;
fStateValue = null;
fConditionOperator = ConditionOperator.NONE;
for (Element condition : childElements) {
+ if (condition == null) {
+ continue;
+ }
fConditions.add(modelFactory.createCondition(condition, fContainer));
}
break;
* @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
*/
ITmfStateValue valueState = (quark != IXmlStateSystemContainer.ROOT_QUARK) ? ss.queryOngoingState(quark) :
filter.getEventFieldValue(event);
+ if (valueState == null) {
+ throw new IllegalStateException();
+ }
return compare(valueState, valueXML, fConditionOperator);
* @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);
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
*/
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);
}
}
* @param event
* The trace event to handle
*/
- public void handleEvent(@NonNull ITmfEvent event) {
+ public void handleEvent(ITmfEvent event) {
if (!appliesToEvent(event)) {
return;
}
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;
* 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);
}
* 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);
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<>();
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);
}
*
* @return The state system associated with this state attribute
*/
- protected ITmfStateSystem getStateSystem() {
+ protected @Nullable ITmfStateSystem getStateSystem() {
return fContainer.getStateSystem();
}
@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) {
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);
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;
* @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);
}
/* 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;
}
/**
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);
* 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)) {
/* 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;
* @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;
/*
* 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);
}
*
* @return The state system associated with the state system container
*/
- protected ITmfStateSystem getStateSystem() {
+ protected @Nullable ITmfStateSystem getStateSystem() {
return fContainer.getStateSystem();
}
*/
@Override
public ITmfStateValue getEventFieldValue(@NonNull ITmfEvent event) {
- return getEventFieldValue(event, fEventField);
+ String eventField = fEventField;
+ if (eventField == null) {
+ throw new IllegalStateException();
+ }
+ return getEventFieldValue(event, eventField);
}
/**
* 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(
* @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 {
--- /dev/null
+/*******************************************************************************
+ * 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;
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;
*/
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) {
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;
@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);
}
}
--- /dev/null
+/*******************************************************************************
+ * 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;
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;
*/
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) {
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;
}
@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);
}
}
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();
}
/* 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: {
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);
}
@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);
}
}
}
@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);
}
@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();
@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) {
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();
private class TmfXmlStateValueDelete extends TmfXmlStateValueTypeReadWrite {
@Override
- public ITmfStateValue getValue(ITmfEvent event) throws AttributeNotFoundException {
+ public ITmfStateValue getValue(@Nullable ITmfEvent event) throws AttributeNotFoundException {
return TmfStateValue.nullValue();
}
}
@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);
*/
if (quarkQuery != IXmlStateSystemContainer.ERROR_QUARK) {
value = ss.queryOngoingState(quarkQuery);
+ if (value == null) {
+ throw new IllegalStateException();
+ }
}
return value;
}
@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) {
--- /dev/null
+/*******************************************************************************
+ * 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;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
}
/* 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);
}
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);
}
/** 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);
}
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