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

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/TCTL/TCTLAtomicPropositionNode.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:
2
2
 
3
3
import dk.aau.cs.TCTL.visitors.ITCTLVisitor;
4
4
 
5
 
 
6
5
// atomic propositions are of the form: <place_name> <operator> n,
7
6
// where <operator> = {<, <=, =, >=, >}
8
7
public class TCTLAtomicPropositionNode extends TCTLAbstractStateProperty {
9
 
        
10
 
        // TODO: make this more object oriented, i.e. use something like TAPNPlace instead of String for places.
 
8
 
 
9
        // TODO: make this more object oriented, i.e. use something like TAPNPlace
 
10
        // instead of String for places.
 
11
        private String template;
11
12
        private String place;
12
13
        private String op;
13
14
        private int n;
14
 
        
 
15
 
15
16
        public String getPlace() {
16
17
                return place;
17
18
        }
18
19
 
 
20
        public String getTemplate() {
 
21
                return template;
 
22
        }
 
23
 
19
24
        public void setPlace(String place) {
20
25
                this.place = place;
21
26
        }
35
40
        public void setN(int n) {
36
41
                this.n = n;
37
42
        }
38
 
        
 
43
 
39
44
        public TCTLAtomicPropositionNode(String place, String op, int n) {
 
45
                this("", place, op, n);
 
46
        }
 
47
 
 
48
        public TCTLAtomicPropositionNode(String template, String place, String op,
 
49
                        int n) {
 
50
                this.template = template;
40
51
                this.place = place;
41
52
                this.op = op;
42
53
                this.n = n;
45
56
 
46
57
        @Override
47
58
        public TCTLAbstractStateProperty copy() {
48
 
                return new TCTLAtomicPropositionNode(place, op, n);
 
59
                return new TCTLAtomicPropositionNode(template, place, op, n);
49
60
        }
50
 
        
 
61
 
51
62
        @Override
52
63
        public boolean equals(Object o) {
53
64
                if (o instanceof TCTLAtomicPropositionNode) {
54
 
                        TCTLAtomicPropositionNode node = (TCTLAtomicPropositionNode)o;
55
 
                        return this.place == node.getPlace() && this.op == node.getOp() && this.n == node.getN();
 
65
                        TCTLAtomicPropositionNode node = (TCTLAtomicPropositionNode) o;
 
66
                        // TODO: Not sure if this is intentional but this is reference
 
67
                        // equals and not equality
 
68
                        return this.template == node.template
 
69
                                        && this.place == node.getPlace() && this.op == node.getOp()
 
70
                                        && this.n == node.getN();
56
71
                }
57
72
                return false;
58
73
        }
59
74
 
60
75
        @Override
61
 
        public TCTLAbstractStateProperty replace(TCTLAbstractProperty object1, TCTLAbstractProperty object2) {
 
76
        public TCTLAbstractStateProperty replace(TCTLAbstractProperty object1,
 
77
                        TCTLAbstractProperty object2) {
62
78
                if (this == object1 && object2 instanceof TCTLAbstractStateProperty) {
63
 
                        TCTLAbstractStateProperty obj2 = (TCTLAbstractStateProperty)object2;
 
79
                        TCTLAbstractStateProperty obj2 = (TCTLAbstractStateProperty) object2;
64
80
                        obj2.setParent(this.parent);
65
81
                        return obj2;
66
82
                } else {
70
86
 
71
87
        @Override
72
88
        public String toString() {
73
 
                return place + "" + op + "" + n;
 
89
                String value = place + "" + op + "" + n;
 
90
                return template == null || template.isEmpty() ? value : template + "."
 
91
                                + value;
74
92
        }
75
 
        
 
93
 
76
94
        @Override
77
95
        public void accept(ITCTLVisitor visitor, Object context) {
78
96
                visitor.visit(this, context);
79
 
                
 
97
 
80
98
        }
81
99
 
82
100
        @Override
88
106
        public boolean containsAtomicPropWithSpecificPlace(String placeName) {
89
107
                return place.equals(placeName);
90
108
        }
91
 
        
 
109
 
 
110
        @Override
92
111
        public TCTLAbstractProperty findFirstPlaceHolder() {
93
112
                return null;
94
113
        }
95
114
 
 
115
        public void setTemplate(String string) {
 
116
                this.template = string;
 
117
        }
 
118
        
 
119
        public boolean containsAtomicPropositionWithSpecificPlaceInTemplate(String templateName, String placeName) {
 
120
                return template.equals(templateName) && place.equals(placeName);
 
121
        }
 
122
 
96
123
}