Commit | Line | Data |
---|---|---|
3a5f73a1 JCK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2016 Ecole Polytechnique de Montreal, Ericsson | |
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 | package org.eclipse.tracecompass.tmf.analysis.xml.core.model; | |
10 | ||
11 | import java.util.List; | |
12 | ||
13 | import org.eclipse.jdt.annotation.Nullable; | |
14 | import org.eclipse.tracecompass.common.core.NonNullUtils; | |
15 | import org.eclipse.tracecompass.tmf.analysis.xml.core.module.IXmlStateSystemContainer; | |
16 | import org.eclipse.tracecompass.tmf.analysis.xml.core.module.XmlUtils; | |
17 | import org.eclipse.tracecompass.tmf.analysis.xml.core.stateprovider.TmfXmlStrings; | |
18 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | |
19 | import org.w3c.dom.Element; | |
20 | import org.w3c.dom.Node; | |
21 | ||
22 | /** | |
23 | * This Class implements a transition input tree in the XML-defined state | |
24 | * system. | |
25 | * | |
26 | * TODO We should merge this class with the current TmfXmlCondition, that should | |
27 | * be kept as is for compatibility with current stateProvider | |
28 | * | |
29 | * @author Jean-Christian Kouame | |
30 | * @since 2.0 | |
31 | */ | |
32 | public class TmfXmlTransitionValidator implements ITmfXmlCondition { | |
33 | ||
34 | IXmlStateSystemContainer fParent; | |
35 | private final String fId; | |
36 | private final ITmfXmlCondition fCondition; | |
37 | ||
38 | /** | |
39 | * Constructor | |
40 | * | |
41 | * @param modelFactory | |
42 | * The factory used to create XML model elements | |
43 | * @param node | |
44 | * The XML root of this transition input | |
45 | * @param parent | |
46 | * The state system container this transition input belongs to | |
47 | */ | |
48 | public TmfXmlTransitionValidator(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer parent) { | |
49 | fParent = parent; | |
50 | fId = node.getAttribute(TmfXmlStrings.ID); | |
51 | ||
52 | List<@Nullable Element> childElements = XmlUtils.getChildElements(node); | |
53 | Node child = NonNullUtils.checkNotNull(childElements.get(0)); | |
54 | fCondition = modelFactory.createCondition((Element) child, parent); | |
55 | } | |
56 | ||
57 | /** | |
58 | * Get the ID of this transition input | |
59 | * | |
60 | * @return The id of this transition input | |
61 | */ | |
62 | public String getId() { | |
63 | return fId; | |
64 | } | |
65 | ||
66 | @Override | |
67 | public boolean test(ITmfEvent event, @Nullable TmfXmlScenarioInfo scenarioInfo) { | |
68 | return fCondition.test(event, scenarioInfo); | |
69 | } | |
70 | } |