1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.stateprovider
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
17 import java
.util
.List
;
19 import org
.eclipse
.core
.runtime
.IPath
;
20 import org
.eclipse
.jdt
.annotation
.NonNull
;
21 import org
.eclipse
.jdt
.annotation
.Nullable
;
22 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.module
.XmlUtils
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.ITmfStateProvider
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
25 import org
.w3c
.dom
.Element
;
28 * Analysis module for the data-driven state systems, defined in XML.
30 * @author Geneviève Bastien
32 public class XmlStateSystemModule
extends TmfStateSystemAnalysisModule
{
34 private @Nullable IPath fXmlFile
;
37 protected StateSystemBackendType
getBackendType() {
38 return StateSystemBackendType
.FULL
;
43 protected ITmfStateProvider
createStateProvider() {
44 return new XmlStateProvider(checkNotNull(getTrace()), getId(), fXmlFile
);
48 public String
getName() {
50 IPath xmlFile
= fXmlFile
;
51 if (xmlFile
== null) {
54 Element doc
= XmlUtils
.getElementInFile(xmlFile
.makeAbsolute().toString(), TmfXmlStrings
.STATE_PROVIDER
, id
);
55 /* Label may be available in XML header */
56 List
<Element
> head
= XmlUtils
.getChildElements(doc
, TmfXmlStrings
.HEAD
);
58 if (head
.size() == 1) {
59 List
<Element
> labels
= XmlUtils
.getChildElements(head
.get(0), TmfXmlStrings
.LABEL
);
60 if (!labels
.isEmpty()) {
61 name
= labels
.get(0).getAttribute(TmfXmlStrings
.VALUE
);
64 return (name
== null) ? id
: name
;
68 * Sets the file path of the XML file containing the state provider
71 * The absolute path to the XML file
73 public void setXmlFile(IPath file
) {
78 * Get the path to the XML file containing this state provider definition.
80 * @return XML file path
82 public IPath
getXmlFile() {