1
package dk.aau.cs.model.NTA;
3
3
import java.util.ArrayList;
5
5
/* Copyright (c) 2009, Kenneth Yrke Jørgensen <kyrke@cs.aau.dk>
8
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
10
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
12
* Neither the name of the TAPAAL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
14
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
10
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
12
* Neither the name of the TAPAAL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
14
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
16
public class TimedAutomaton {
17
17
private ArrayList<Edge> transitions = new ArrayList<Edge>();
18
18
private ArrayList<Location> locations = new ArrayList<Location>();
20
20
private String declarations = "";
21
21
private String parameters = "";
23
23
private String name = "";
25
25
private Location initialLocation;
27
public TimedAutomaton(){
27
public TimedAutomaton() {
31
public TimedAutomaton(String name, ArrayList<Edge> transitions, ArrayList<Location> locations, Location initLocation, String parameters)
31
public TimedAutomaton(String name, ArrayList<Edge> transitions,
32
ArrayList<Location> locations, Location initLocation,
33
34
this(name, transitions, locations, initLocation);
35
36
this.parameters = parameters;
38
public TimedAutomaton(String name, ArrayList<Edge> transitions, ArrayList<Location> locations, Location initLocation)
39
public TimedAutomaton(String name, ArrayList<Edge> transitions,
40
ArrayList<Location> locations, Location initLocation) {
41
42
this.transitions = transitions;
42
43
this.locations = locations;
43
44
initialLocation = initLocation;
46
public Location getInitLocation()
47
public Location getInitLocation() {
48
48
return initialLocation;
51
public void setInitLocation(Location initLocation)
51
public void setInitLocation(Location initLocation) {
53
52
initialLocation = initLocation;
56
public String getName()
55
public String getName() {
61
public void setName(String name)
59
public void setName(String name) {
66
public String getParameters()
63
public String getParameters() {
71
public void setParameters(String parameters)
67
public void setParameters(String parameters) {
73
68
this.parameters = parameters;
77
public ArrayList<Edge> getTransitions()
71
public ArrayList<Edge> getTransitions() {
79
72
return transitions;
82
public void setTransitions(ArrayList<Edge> transitions)
75
public void setTransitions(ArrayList<Edge> transitions) {
84
76
this.transitions = transitions;
87
public ArrayList<Location> getLocations()
79
public ArrayList<Location> getLocations() {
92
public void setLocations(ArrayList<Location> locations)
83
public void setLocations(ArrayList<Location> locations) {
94
84
this.locations = locations;
97
public String getDeclarations()
87
public String getDeclarations() {
99
88
return declarations;
102
public void setDeclarations(String declarations)
91
public void setDeclarations(String declarations) {
104
92
this.declarations = declarations;
107
public void addLocation(Location l)
95
public void addLocation(Location l) {
112
public void addTransition(Edge e)
99
public void addTransition(Edge e) {
114
100
transitions.add(e);
117
public StringBuffer toXML()
103
public StringBuffer toXML() {
119
104
StringBuffer res = new StringBuffer();
121
106
res.append("<template>\n");
122
107
res.append("<name x=\"5\" y=\"5\">" + name + "</name>\n");
124
if(!parameters.equals(""))
109
if (!parameters.equals(""))
125
110
res.append("<parameter>" + parameters + "</parameter>\n");
127
if(!declarations.equals(""))
112
if (!declarations.equals(""))
128
113
res.append("<declaration>" + declarations + "</declaration>\n");
131
116
StringBuffer a = new StringBuffer();
133
for(Location l : locations)
118
for (Location l : locations) {
139
123
// initial location
140
124
res.append("<init ref=\"a" + initialLocation.getID() + "\" />\n");
143
for(Edge t : transitions)
127
for (Edge t : transitions) {
149
132
res.append("</template>\n");