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

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/model/NTA/Edge.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
/*  Copyright (c) 2009, Kenneth Yrke Jørgensen <kyrke@cs.aau.dk>
3
 
All rights reserved.
4
 
 
5
 
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
 
 
7
 
    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
 
    * 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.
9
 
    * 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.
10
 
 
11
 
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.   
 
4
 All rights reserved.
 
5
 
 
6
 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 
7
 
 
8
 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 
9
 * 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.
 
10
 * 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.
 
11
 
 
12
 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.   
12
13
 */
13
14
public class Edge {
14
15
 
15
16
        private String guard = "";
16
17
        private String sync = "";
17
18
        private String update = "";
18
 
        
 
19
 
19
20
        private Location source;
20
21
        private Location dest;
21
 
        
22
 
        
23
 
        public Edge(Location source, Location dest, String guard, String sync, String update)
24
 
        {
 
22
 
 
23
        public Edge(Location source, Location dest, String guard, String sync,
 
24
                        String update) {
25
25
                this.source = source;
26
26
                this.dest = dest;
27
27
                this.guard = guard;
28
28
                this.sync = sync;
29
29
                this.update = update;
30
30
        }
31
 
        
32
 
        public Location getSource()
33
 
        {
 
31
 
 
32
        public Location getSource() {
34
33
                return source;
35
34
        }
36
 
        
37
 
        public void setSource(Location source)
38
 
        {
 
35
 
 
36
        public void setSource(Location source) {
39
37
                this.source = source;
40
38
        }
41
 
        
42
 
        public Location getDestination()
43
 
        {
 
39
 
 
40
        public Location getDestination() {
44
41
                return dest;
45
42
        }
46
 
        
47
 
        public void setDestination(Location dest)
48
 
        {
 
43
 
 
44
        public void setDestination(Location dest) {
49
45
                this.dest = dest;
50
46
        }
51
 
        
52
 
        public String getGuard()
53
 
        {
 
47
 
 
48
        public String getGuard() {
54
49
                return guard;
55
50
        }
56
 
        
57
 
        public void setGuard(String guard)
58
 
        {
 
51
 
 
52
        public void setGuard(String guard) {
59
53
                // TODO: check guard conforms to what is allowed
60
54
                this.guard = guard;
61
55
        }
62
 
        
63
 
        public String getSync()
64
 
        {
 
56
 
 
57
        public String getSync() {
65
58
                return sync;
66
59
        }
67
 
        
68
 
        public void setSync(String sync)
69
 
        {
 
60
 
 
61
        public void setSync(String sync) {
70
62
                // TODO: check sync conforms to what is allowed in uppaal
71
63
                this.sync = sync;
72
64
        }
73
 
        
74
 
        public String getUpdate()
75
 
        {
 
65
 
 
66
        public String getUpdate() {
76
67
                return update;
77
68
        }
78
 
        
79
 
        public void setUpdate(String update)
80
 
        {
81
 
                //TODO: check update conforms to what is allowed in uppaal
 
69
 
 
70
        public void setUpdate(String update) {
 
71
                // TODO: check update conforms to what is allowed in uppaal
82
72
                this.update = update;
83
73
        }
84
 
        
85
 
        public StringBuffer toXML()
86
 
        {
 
74
 
 
75
        public StringBuffer toXML() {
87
76
                StringBuffer res = new StringBuffer();
88
 
                
 
77
 
89
78
                res.append("<transition>\n");
90
79
                res.append("<source ref=\"a" + source.getID() + "\" />\n");
91
80
                res.append("<target ref=\"a" + dest.getID() + "\" />\n");
92
 
                
93
 
                // replace "<" and ">" in guard with "&lt;" and "&gt;" respectively and replace "&&" with "&amp;&amp;"
 
81
 
 
82
                // replace "<" and ">" in guard with "&lt;" and "&gt;" respectively and
 
83
                // replace "&&" with "&amp;&amp;"
94
84
                String tmp = guard.replace("<", "&lt;").replace(">", "&gt;");
95
85
                tmp = tmp.replace("&&", "&amp;&amp;");
96
 
                
 
86
 
97
87
                res.append("<label kind=\"guard\">" + tmp + "</label>\n");
98
88
                res.append("<label kind=\"synchronisation\">" + sync + "</label>\n");
99
89
                res.append("<label kind=\"assignment\">" + update + "</label>\n");
100
 
                
 
90
 
101
91
                res.append("</transition>\n");
102
92
                return res;
103
93
        }
104
 
        
 
94
 
105
95
        @Override
106
 
        public String toString(){
107
 
                return "Edge from " + source.getID() + " to " + dest.getID() + ". Guard: " + guard + ", Sync: " + sync + ", Update: " + update;
 
96
        public String toString() {
 
97
                return "Edge from " + source.getName() + " to " + dest.getName()
 
98
                                + ". Guard: " + guard + ", Sync: " + sync + ", Update: "
 
99
                                + update;
108
100
        }
109
101
}