~tapaal-contributor/tapaal/disappearing-tokens-1940098

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/model/NTA/TimedAutomaton.java

  • Committer: Kenneth Yrke Jørgensen
  • Date: 2011-04-12 09:50:16 UTC
  • mfrom: (329.1.188 tapaal-1.5)
  • Revision ID: mail@yrke.dk-20110412095016-e4hqdgab5596ja09
Merged with branch addning support for new 1.5 features

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package dk.aau.cs.TA;
 
1
package dk.aau.cs.model.NTA;
2
2
 
3
3
import java.util.ArrayList;
4
4
 
5
5
/*  Copyright (c) 2009, Kenneth Yrke Jørgensen <kyrke@cs.aau.dk>
6
 
All rights reserved.
7
 
 
8
 
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9
 
 
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.
13
 
 
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.   
 
6
 All rights reserved.
 
7
 
 
8
 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 
9
 
 
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.
 
13
 
 
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.   
15
15
 */
16
16
public class TimedAutomaton {
17
17
        private ArrayList<Edge> transitions = new ArrayList<Edge>();
18
18
        private ArrayList<Location> locations = new ArrayList<Location>();
19
 
        
 
19
 
20
20
        private String declarations = "";
21
21
        private String parameters = "";
22
 
        
 
22
 
23
23
        private String name = "";
24
 
        
 
24
 
25
25
        private Location initialLocation;
26
 
        
27
 
        public TimedAutomaton(){
28
 
                
 
26
 
 
27
        public TimedAutomaton() {
 
28
 
29
29
        }
30
 
        
31
 
        public TimedAutomaton(String name, ArrayList<Edge> transitions, ArrayList<Location> locations, Location initLocation, String parameters)
32
 
        {
 
30
 
 
31
        public TimedAutomaton(String name, ArrayList<Edge> transitions,
 
32
                        ArrayList<Location> locations, Location initLocation,
 
33
                        String parameters) {
33
34
                this(name, transitions, locations, initLocation);
34
 
                
 
35
 
35
36
                this.parameters = parameters;
36
37
        }
37
 
        
38
 
        public TimedAutomaton(String name, ArrayList<Edge> transitions, ArrayList<Location> locations, Location initLocation)
39
 
        {
 
38
 
 
39
        public TimedAutomaton(String name, ArrayList<Edge> transitions,
 
40
                        ArrayList<Location> locations, Location initLocation) {
40
41
                this.name = name;
41
42
                this.transitions = transitions;
42
43
                this.locations = locations;
43
44
                initialLocation = initLocation;
44
45
        }
45
 
        
46
 
        public Location getInitLocation()
47
 
        {
 
46
 
 
47
        public Location getInitLocation() {
48
48
                return initialLocation;
49
49
        }
50
 
        
51
 
        public void setInitLocation(Location initLocation)
52
 
        {
 
50
 
 
51
        public void setInitLocation(Location initLocation) {
53
52
                initialLocation = initLocation;
54
53
        }
55
 
        
56
 
        public String getName()
57
 
        {
 
54
 
 
55
        public String getName() {
58
56
                return name;
59
57
        }
60
 
        
61
 
        public void setName(String name)
62
 
        {
 
58
 
 
59
        public void setName(String name) {
63
60
                this.name = name;
64
61
        }
65
 
        
66
 
        public String getParameters()
67
 
        {
 
62
 
 
63
        public String getParameters() {
68
64
                return parameters;
69
65
        }
70
 
        
71
 
        public void setParameters(String parameters)
72
 
        {
 
66
 
 
67
        public void setParameters(String parameters) {
73
68
                this.parameters = parameters;
74
69
        }
75
 
        
76
 
        
77
 
        public ArrayList<Edge> getTransitions()
78
 
        {
 
70
 
 
71
        public ArrayList<Edge> getTransitions() {
79
72
                return transitions;
80
73
        }
81
 
        
82
 
        public void setTransitions(ArrayList<Edge> transitions)
83
 
        {
 
74
 
 
75
        public void setTransitions(ArrayList<Edge> transitions) {
84
76
                this.transitions = transitions;
85
77
        }
86
 
        
87
 
        public ArrayList<Location> getLocations()
88
 
        {
 
78
 
 
79
        public ArrayList<Location> getLocations() {
89
80
                return locations;
90
81
        }
91
 
        
92
 
        public void setLocations(ArrayList<Location> locations)
93
 
        {
 
82
 
 
83
        public void setLocations(ArrayList<Location> locations) {
94
84
                this.locations = locations;
95
85
        }
96
 
        
97
 
        public String getDeclarations()
98
 
        {
 
86
 
 
87
        public String getDeclarations() {
99
88
                return declarations;
100
89
        }
101
 
        
102
 
        public void setDeclarations(String declarations)
103
 
        {
 
90
 
 
91
        public void setDeclarations(String declarations) {
104
92
                this.declarations = declarations;
105
93
        }
106
 
        
107
 
        public void addLocation(Location l)
108
 
        {
 
94
 
 
95
        public void addLocation(Location l) {
109
96
                locations.add(l);
110
97
        }
111
 
        
112
 
        public void addTransition(Edge e)
113
 
        {
 
98
 
 
99
        public void addTransition(Edge e) {
114
100
                transitions.add(e);
115
101
        }
116
 
        
117
 
        public StringBuffer toXML()
118
 
        {
 
102
 
 
103
        public StringBuffer toXML() {
119
104
                StringBuffer res = new StringBuffer();
120
 
                
 
105
 
121
106
                res.append("<template>\n");
122
107
                res.append("<name x=\"5\" y=\"5\">" + name + "</name>\n");
123
 
                
124
 
                if(!parameters.equals(""))
 
108
 
 
109
                if (!parameters.equals(""))
125
110
                        res.append("<parameter>" + parameters + "</parameter>\n");
126
 
                
127
 
                if(!declarations.equals(""))
 
111
 
 
112
                if (!declarations.equals(""))
128
113
                        res.append("<declaration>" + declarations + "</declaration>\n");
129
 
                
 
114
 
130
115
                // locations
131
116
                StringBuffer a = new StringBuffer();
132
 
                
133
 
                for(Location l : locations)
134
 
                {
 
117
 
 
118
                for (Location l : locations) {
135
119
                        a = l.toXML();
136
120
                        res.append(a);
137
121
                }
138
 
                
 
122
 
139
123
                // initial location
140
124
                res.append("<init ref=\"a" + initialLocation.getID() + "\" />\n");
141
 
                
 
125
 
142
126
                // transitions
143
 
                for(Edge t : transitions)
144
 
                {
 
127
                for (Edge t : transitions) {
145
128
                        a = t.toXML();
146
129
                        res.append(a);
147
130
                }
148
 
                
 
131
 
149
132
                res.append("</template>\n");
150
 
                
 
133
 
151
134
                return res;
152
135
        }
153
136
}