1 /*******************************************************************************
2 * Copyright (c) 2014 É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 java
.util
.List
;
17 import org
.eclipse
.core
.runtime
.IPath
;
18 import org
.eclipse
.jdt
.annotation
.NonNull
;
19 import org
.eclipse
.jdt
.annotation
.Nullable
;
20 import org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.core
.module
.XmlUtils
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.ITmfStateProvider
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
23 import org
.w3c
.dom
.Element
;
26 * Analysis module for the data-driven state systems, defined in XML.
28 * @author Geneviève Bastien
31 public class XmlStateSystemModule
extends TmfStateSystemAnalysisModule
{
33 private @Nullable IPath fXmlFile
;
36 protected StateSystemBackendType
getBackendType() {
37 return StateSystemBackendType
.FULL
;
42 protected ITmfStateProvider
createStateProvider() {
43 return new XmlStateProvider(getTrace(), getId(), fXmlFile
);
47 public String
getName() {
49 IPath xmlFile
= fXmlFile
;
50 if (xmlFile
== null) {
53 Element doc
= XmlUtils
.getElementInFile(xmlFile
.makeAbsolute().toString(), TmfXmlStrings
.STATE_PROVIDER
, id
);
54 /* Label may be available in XML header */
55 List
<Element
> head
= XmlUtils
.getChildElements(doc
, TmfXmlStrings
.HEAD
);
57 if (head
.size() == 1) {
58 List
<Element
> labels
= XmlUtils
.getChildElements(head
.get(0), TmfXmlStrings
.LABEL
);
59 if (!labels
.isEmpty()) {
60 name
= labels
.get(0).getAttribute(TmfXmlStrings
.VALUE
);
63 return (name
== null) ? id
: name
;
67 * Sets the file path of the XML file containing the state provider
70 * The absolute path to the XML file
72 public void setXmlFile(IPath file
) {
77 * Get the path to the XML file containing this state provider definition.
79 * @return XML file path
81 public IPath
getXmlFile() {