2
* Copyright © 2008-2012 NetAllied Systems GmbH, Ravensburg, Germany.
4
* Licensed under the MIT Open Source License,
5
* for details please see LICENSE file or the website
6
* http://www.opensource.org/licenses/mit-license.php
8
package de.netallied.xsd2cppsax.statemachine;
10
import java.util.ArrayList;
11
import java.util.List;
12
import java.util.SortedMap;
13
import java.util.SortedSet;
14
import java.util.TreeMap;
15
import java.util.TreeSet;
18
* Specialized node which allows querying of nodes by name.
21
public class StateMachineRootNode extends StateMachineNode {
23
/** Contains all nodes of this StateMachine. */
24
private SortedMap<String, List<StateMachineNode>> nodes = new TreeMap<String, List<StateMachineNode>>();
29
public StateMachineRootNode(String name) {
31
registerNode(name, this);
35
* Finds nodes with given name in this state machine.
38
* Name to find nodes with.
39
* @return Nodes with given name.
41
public List<StateMachineNode> findNodes(String name) {
42
return nodes.get(name);
46
* @return All node names in this state machine.
48
protected SortedSet<String> getNodeNames() {
49
SortedSet<String> sortedNames = new TreeSet<String>();
50
sortedNames.addAll(nodes.keySet());
55
* Registers a new node. To be called when a node is added to this state
63
protected void registerNode(String name, StateMachineNode node) {
64
List<StateMachineNode> nodesList = nodes.get(name);
65
if (nodesList == null) {
66
nodes.put(name, new ArrayList<StateMachineNode>());
67
nodesList = nodes.get(name);