lttng.ust: Add the build-ID to the key of cache of addr2line calls
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.core / src / org / eclipse / tracecompass / tmf / analysis / xml / core / stateprovider / XmlStateSystemModule.java
1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 École Polytechnique de Montréal
3 *
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
8 *
9 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider;
14
15 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
16
17 import java.util.List;
18
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;
26
27 /**
28 * Analysis module for the data-driven state systems, defined in XML.
29 *
30 * @author Geneviève Bastien
31 */
32 public class XmlStateSystemModule extends TmfStateSystemAnalysisModule {
33
34 private @Nullable IPath fXmlFile;
35
36 @Override
37 protected StateSystemBackendType getBackendType() {
38 return StateSystemBackendType.FULL;
39 }
40
41 @Override
42 @NonNull
43 protected ITmfStateProvider createStateProvider() {
44 return new XmlStateProvider(checkNotNull(getTrace()), getId(), fXmlFile);
45 }
46
47 @Override
48 public String getName() {
49 String id = getId();
50 IPath xmlFile = fXmlFile;
51 if (xmlFile == null) {
52 return id;
53 }
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);
57 String name = null;
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);
62 }
63 }
64 return (name == null) ? id : name;
65 }
66
67 /**
68 * Sets the file path of the XML file containing the state provider
69 *
70 * @param file
71 * The absolute path to the XML file
72 */
73 public void setXmlFile(IPath file) {
74 fXmlFile = file;
75 }
76
77 /**
78 * Get the path to the XML file containing this state provider definition.
79 *
80 * @return XML file path
81 */
82 public IPath getXmlFile() {
83 return fXmlFile;
84 }
85
86 }
This page took 0.084331 seconds and 5 git commands to generate.