1 /*******************************************************************************
2 * Copyright (c) 2016 Ecole Polytechnique de Montreal, Ericsson
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
;
11 import java
.util
.List
;
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
;
23 * This Class implements a transition input tree in the XML-defined state
26 * TODO We should merge this class with the current TmfXmlCondition, that should
27 * be kept as is for compatibility with current stateProvider
29 * @author Jean-Christian Kouame
32 public class TmfXmlTransitionValidator
implements ITmfXmlCondition
{
34 IXmlStateSystemContainer fParent
;
35 private final String fId
;
36 private final ITmfXmlCondition fCondition
;
42 * The factory used to create XML model elements
44 * The XML root of this transition input
46 * The state system container this transition input belongs to
48 public TmfXmlTransitionValidator(ITmfXmlModelFactory modelFactory
, Element node
, IXmlStateSystemContainer parent
) {
50 fId
= node
.getAttribute(TmfXmlStrings
.ID
);
52 List
<@Nullable Element
> childElements
= XmlUtils
.getChildElements(node
);
53 Node child
= NonNullUtils
.checkNotNull(childElements
.get(0));
54 fCondition
= modelFactory
.createCondition((Element
) child
, parent
);
58 * Get the ID of this transition input
60 * @return The id of this transition input
62 public String
getId() {
67 public boolean test(ITmfEvent event
, @Nullable TmfXmlScenarioInfo scenarioInfo
) {
68 return fCondition
.test(event
, scenarioInfo
);