getRelationType()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
package it.cnr.istc.pst.platinum.ai.lang.ddl.v3.parser;
2
3
import org.antlr.runtime.Token;
4
import org.antlr.runtime.tree.CommonTree;
5
6
/**
7
 *
8
 * @author Riccardo De Benedictis
9
 */
10
public class DDLTemporalRelationType extends CommonTree {
11
12
    private DDLRange firstRange;
13
    private DDLRange secondRange;
14
    private TemporalRelationType relationType;
15
16
    public DDLTemporalRelationType(Token payload) {
17
        super(payload);
18
    }
19
20
    void parse() 
21
    {
22
        String relation_type = getText();
23
        if (relation_type.equals("MEETS")) {
24
            relationType = TemporalRelationType.MEETS;
25
            return;
26
        }
27
        if (relation_type.equals("MET-BY")) {
28
            relationType = TemporalRelationType.MET_BY;
29
            return;
30
        }
31
        if (relation_type.equals("BEFORE")) {
32
            relationType = TemporalRelationType.BEFORE;
33
            firstRange = (DDLRange) getChild(0);
34
            firstRange.parse();
35
            return;
36
        }
37
        if (relation_type.equals("AFTER")) {
38
            relationType = TemporalRelationType.AFTER;
39
            firstRange = (DDLRange) getChild(0);
40
            firstRange.parse();
41
            return;
42
        }
43
        if (relation_type.equals("EQUALS")) {
44
            relationType = TemporalRelationType.EQUALS;
45
            return;
46
        }
47
        if (relation_type.equals("STARTS")) {
48
            relationType = TemporalRelationType.STARTS;
49
            return;
50
        }
51
        if (relation_type.equals("STARTED-BY")) {
52
            relationType = TemporalRelationType.STARTED_BY;
53
            return;
54
        }
55
        if (relation_type.equals("FINISHES")) {
56
            relationType = TemporalRelationType.FINISHES;
57
            return;
58
        }
59
        if (relation_type.equals("FINISHED-BY")) {
60
            relationType = TemporalRelationType.FINISHED_BY;
61
            return;
62
        }
63
        if (relation_type.equals("DURING")) {
64
            relationType = TemporalRelationType.DURING;
65
            firstRange = (DDLRange) getChild(0);
66
            firstRange.parse();
67
            secondRange = (DDLRange) getChild(1);
68
            secondRange.parse();
69
            return;
70
        }
71
        if (relation_type.equals("CONTAINS")) {
72
            relationType = TemporalRelationType.CONTAINS;
73
            firstRange = (DDLRange) getChild(0);
74
            firstRange.parse();
75
            secondRange = (DDLRange) getChild(1);
76
            secondRange.parse();
77
            return;
78
        }
79
        if (relation_type.equals("OVERLAPS")) {
80
            relationType = TemporalRelationType.OVERLAPS;
81
            firstRange = (DDLRange) getChild(0);
82
            firstRange.parse();
83
            return;
84
        }
85
        if (relation_type.equals("OVERLAPPED-BY")) {
86
            relationType = TemporalRelationType.OVERLAPPED_BY;
87
            firstRange = (DDLRange) getChild(0);
88
            firstRange.parse();
89
            return;
90
        }
91
        if (relation_type.equals("STARTS-AT")) {
92
            relationType = TemporalRelationType.STARTS_AT;
93
            return;
94
        }
95
        if (relation_type.equals("ENDS-AT")) {
96
            relationType = TemporalRelationType.ENDS_AT;
97
            return;
98
        }
99
        if (relation_type.equals("AT-START")) {
100
            relationType = TemporalRelationType.AT_START;
101
            return;
102
        }
103
        if (relation_type.equals("AT_END")) {
104
            relationType = TemporalRelationType.AT_END;
105
            return;
106
        }
107
        if (relation_type.equals("BEFORE-START")) {
108
            relationType = TemporalRelationType.BEFORE_START;
109
            firstRange = (DDLRange) getChild(0);
110
            firstRange.parse();
111
            return;
112
        }
113
        if (relation_type.equals("AFTER-END")) {
114
            relationType = TemporalRelationType.AFTER_END;
115
            firstRange = (DDLRange) getChild(0);
116
            firstRange.parse();
117
            return;
118
        }
119
        if (relation_type.equals("START-START")) {
120
            relationType = TemporalRelationType.START_START;
121
            firstRange = (DDLRange) getChild(0);
122
            firstRange.parse();
123
            return;
124
        }
125
        if (relation_type.equals("START-END")) {
126
            relationType = TemporalRelationType.START_END;
127
            firstRange = (DDLRange) getChild(0);
128
            firstRange.parse();
129
            return;
130
        }
131
        if (relation_type.equals("END-START")) {
132
            relationType = TemporalRelationType.END_START;
133
            firstRange = (DDLRange) getChild(0);
134
            firstRange.parse();
135
            return;
136
        }
137
        if (relation_type.equals("END-END")) {
138
            relationType = TemporalRelationType.END_END;
139
            firstRange = (DDLRange) getChild(0);
140
            firstRange.parse();
141
            return;
142
        }
143
        if (relation_type.equals("CONTAINS-START")) {
144
            relationType = TemporalRelationType.CONTAINS_START;
145
            firstRange = (DDLRange) getChild(0);
146
            firstRange.parse();
147
            secondRange = (DDLRange) getChild(1);
148
            secondRange.parse();
149
            return;
150
        }
151
        if (relation_type.equals("CONTAINS-END")) {
152
            relationType = TemporalRelationType.CONTAINS_END;
153
            firstRange = (DDLRange) getChild(0);
154
            firstRange.parse();
155
            secondRange = (DDLRange) getChild(1);
156
            secondRange.parse();
157
            return;
158
        }
159
        if (relation_type.equals("STARTS-DURING")) {
160
            relationType = TemporalRelationType.STARTS_DURING;
161
            firstRange = (DDLRange) getChild(0);
162
            firstRange.parse();
163
            secondRange = (DDLRange) getChild(1);
164
            secondRange.parse();
165
            return;
166
        }
167
        if (relation_type.equals("ENDS-DURING")) {
168
            relationType = TemporalRelationType.ENDS_DURING;
169
            firstRange = (DDLRange) getChild(0);
170
            firstRange.parse();
171
            secondRange = (DDLRange) getChild(1);
172
            secondRange.parse();
173
            return;
174
        }
175
    }
176
177
    /**
178
     * @return the firstRange
179
     */
180
    public DDLRange getFirstRange() {
181
        return firstRange;
182
    }
183
184
    /**
185
     * @return the secondRange
186
     */
187
    public DDLRange getSecondRange() {
188
        return secondRange;
189
    }
190
191
    /**
192
     * @return the relationType
193
     */
194
    public TemporalRelationType getRelationType() {
195
        return relationType;
196
    }
197
198
    public enum TemporalRelationType {
199
200
        MEETS,
201
        MET_BY,
202
        BEFORE,
203
        AFTER,
204
        EQUALS,
205
        STARTS,
206
        STARTED_BY,
207
        FINISHES,
208
        FINISHED_BY,
209
        DURING,
210
        CONTAINS,
211
        OVERLAPS,
212
        OVERLAPPED_BY,
213
        STARTS_AT,
214
        ENDS_AT,
215
        AT_START,
216
        AT_END,
217
        BEFORE_START,
218
        AFTER_END,
219
        START_START,
220
        START_END,
221
        END_START,
222
        END_END,
223
        CONTAINS_START,
224
        CONTAINS_END,
225
        STARTS_DURING,
226
        ENDS_DURING;
227
    }
228
}
229