line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Ogmios::Annotations::Element; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
98
|
use strict; |
|
16
|
|
|
|
|
26
|
|
|
16
|
|
|
|
|
636
|
|
4
|
16
|
|
|
16
|
|
65
|
use warnings; |
|
16
|
|
|
|
|
21
|
|
|
16
|
|
|
|
|
27240
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new |
8
|
|
|
|
|
|
|
{ |
9
|
0
|
|
|
0
|
0
|
|
my ($class, $fields) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
0
|
|
|
|
|
if (!defined $fields->{'id'}) { |
12
|
0
|
|
|
|
|
|
die("id is not defined"); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $element = { |
16
|
|
|
|
|
|
|
'id' => $fields->{'id'}, |
17
|
|
|
|
|
|
|
'log_id' => undef, |
18
|
|
|
|
|
|
|
'form' => undef, |
19
|
|
|
|
|
|
|
'next' => undef, |
20
|
|
|
|
|
|
|
'previous' => undef, |
21
|
|
|
|
|
|
|
}; |
22
|
0
|
|
|
|
|
|
bless ($element,$class); |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
if (defined $fields->{'log_id'}) { |
25
|
0
|
|
|
|
|
|
$element->setLogId($fields->{'log_id'}); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
if (defined $fields->{'form'}) { |
29
|
0
|
|
|
|
|
|
$element->setForm($fields->{'form'}); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return $element; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub next { |
36
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
$self->{'next'} = shift if @_; |
39
|
0
|
|
|
|
|
|
return($self->{'next'}); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub previous { |
43
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
$self->{'previous'} = shift if @_; |
46
|
0
|
|
|
|
|
|
return($self->{'previous'}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub equals { |
50
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if ($self->getId == $element->getId) { |
53
|
0
|
|
|
|
|
|
return(1); |
54
|
|
|
|
|
|
|
} else { |
55
|
0
|
|
|
|
|
|
return(0); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _getField { |
60
|
0
|
|
|
0
|
|
|
my ($self, $field) = @_; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return($self->{$field}); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _setField { |
66
|
0
|
|
|
0
|
|
|
my ($self, $field, $value) = @_; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$self->{$field} = $value; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub getId { |
72
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return($self->{'id'}); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub setId { |
78
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$self->{'id'} = $id; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub getLogId { |
84
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return($self->{'log_id'}); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub setLogId { |
90
|
0
|
|
|
0
|
0
|
|
my ($self, $log_id) = @_; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$self->{'log_id'} = $log_id; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub getForm { |
96
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return($self->{'form'}); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub setForm { |
102
|
0
|
|
|
0
|
0
|
|
my ($self, $form) = @_; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# $self->{'form'} = $self->_xmlencode($form); |
105
|
0
|
|
|
|
|
|
$self->{'form'} = $form; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub print { |
110
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $field; |
113
|
0
|
|
|
|
|
|
foreach $field (keys %$self) { |
114
|
0
|
0
|
|
|
|
|
if (defined $self->{$field}) { |
115
|
0
|
|
|
|
|
|
warn "$field => " . $self->{$field} . "\n"; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub printXML { |
122
|
0
|
|
|
0
|
0
|
|
my ($self, $name, $order) = @_; |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
print $self->XMLout($name, $order); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub _XMLoutField { |
128
|
0
|
|
|
0
|
|
|
my ($self, $field, $field_content, $shift) = @_; |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
my $str; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my $elt; |
133
|
0
|
|
|
|
|
|
my $internal_field; |
134
|
0
|
|
|
|
|
|
my $position; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
if (!defined($shift)) { |
138
|
0
|
|
|
|
|
|
$shift = "\t\t"; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# warn "$field - " . ref($field_content) . "\n"; |
142
|
0
|
0
|
|
|
|
|
if (ref($field_content) eq "ARRAY") { |
143
|
0
|
|
|
|
|
|
$position = index($field, "list_"); |
144
|
0
|
0
|
|
|
|
|
if ($position == 0) { |
145
|
0
|
|
|
|
|
|
$str .= "$shift<$field>\n"; |
146
|
0
|
|
|
|
|
|
$internal_field = substr($field, $position + 5); |
147
|
0
|
|
|
|
|
|
foreach $elt (@{$field_content}) { |
|
0
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($internal_field, $elt, "$shift\t"); |
149
|
|
|
|
|
|
|
} |
150
|
0
|
|
|
|
|
|
$str .= "$shift$field>\n"; |
151
|
|
|
|
|
|
|
} else { |
152
|
0
|
|
|
|
|
|
foreach $elt (@{$field_content}) { |
|
0
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($field, $elt, "$shift"); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
0
|
0
|
|
|
|
|
if (ref($field_content) eq "HASH") { |
159
|
0
|
|
|
|
|
|
$str .= "$shift<$field>\n"; |
160
|
0
|
0
|
|
|
|
|
if (defined($internal_field = $field_content->{"reference"})) { |
161
|
0
|
|
|
|
|
|
foreach $elt (@{$field_content->{$field_content->{"reference"}}}) { |
|
0
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($internal_field, $elt, "$shift\t"); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} else { |
165
|
0
|
0
|
|
|
|
|
if ($field eq "weights") { |
166
|
0
|
|
|
|
|
|
foreach $elt (keys %$field_content) { |
167
|
|
|
|
|
|
|
# if (!defined ($field_content->{$elt})) { |
168
|
|
|
|
|
|
|
# warn "$elt\n"; |
169
|
|
|
|
|
|
|
# } |
170
|
0
|
|
|
|
|
|
$str .= "$shift\t"; |
171
|
0
|
|
|
|
|
|
$str .= $field_content->{$elt} . "\n"; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} else { |
174
|
0
|
|
|
|
|
|
foreach $elt (keys %$field_content) { |
175
|
|
|
|
|
|
|
# $str .= "$shift<$elt>" . $field_content->{$elt} . "$elt>\n"; |
176
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($elt,$field_content->{$elt},"$shift\t"); #"$shift<$elt>" . $field_content->{$elt} . "$elt>\n"; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
} |
180
|
0
|
|
|
|
|
|
$str .= "$shift$field>\n"; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
0
|
0
|
|
|
|
|
if (index(ref($field_content), "Lingua::Ogmios") > -1) { |
184
|
|
|
|
|
|
|
# warn "$field: " . $field_content->getId . "\n"; |
185
|
0
|
|
|
|
|
|
$str .= "$shift<$field>"; |
186
|
|
|
|
|
|
|
# $str .= $field_content->getId . " = " . $field_content; |
187
|
0
|
|
|
|
|
|
$str .= $field_content->getId; |
188
|
0
|
|
|
|
|
|
$str .= "$field>\n"; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
0
|
0
|
|
|
|
|
if (ref($field_content) eq "") { |
192
|
0
|
|
|
|
|
|
$str .= "$shift<$field>"; |
193
|
0
|
|
|
|
|
|
$str .= $field_content; |
194
|
0
|
|
|
|
|
|
$str .= "$field>\n"; |
195
|
|
|
|
|
|
|
} |
196
|
0
|
|
|
|
|
|
return($str); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub XMLout { |
200
|
0
|
|
|
0
|
0
|
|
my ($self, $name, $order) = @_; |
201
|
0
|
|
|
|
|
|
my $field; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
my $str; |
204
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
|
my $elt; |
206
|
0
|
|
|
|
|
|
my $internal_field; |
207
|
0
|
|
|
|
|
|
my $position; |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# warn "$name\n"; |
210
|
0
|
|
|
|
|
|
$str = "\t<$name>\n"; |
211
|
0
|
|
|
|
|
|
foreach $field (@$order) { |
212
|
|
|
|
|
|
|
# warn "-->$field\n"; |
213
|
0
|
0
|
|
|
|
|
if (defined $self->_getField($field)) { |
214
|
0
|
0
|
0
|
|
|
|
if ((defined(ref($self->_getField($field)))) && (ref($self->_getField($field)) ne "")) { |
215
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($field, $self->_getField($field), "\t\t") ; |
216
|
|
|
|
|
|
|
} else { |
217
|
0
|
|
|
|
|
|
$str .= "\t\t<$field>" . $self->_xmlencode($self->_getField($field)) . "$field>\n"; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
} |
221
|
0
|
|
|
|
|
|
$str .= "\t$name>\n"; |
222
|
0
|
|
|
|
|
|
return($str); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub XMLout_orig { |
226
|
0
|
|
|
0
|
0
|
|
my ($self, $name, $order) = @_; |
227
|
0
|
|
|
|
|
|
my $field; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
my $str; |
230
|
|
|
|
|
|
|
|
231
|
0
|
|
|
|
|
|
my $elt; |
232
|
0
|
|
|
|
|
|
my $internal_field; |
233
|
0
|
|
|
|
|
|
my $position; |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
$str = "\t<$name>\n"; |
236
|
0
|
|
|
|
|
|
foreach $field (@$order) { |
237
|
0
|
0
|
|
|
|
|
if (defined $self->_getField($field)) { |
238
|
0
|
0
|
|
|
|
|
if (ref $self->_getField($field) eq "ARRAY") { |
239
|
0
|
|
|
|
|
|
$str .= "\t\t<$field>"; |
240
|
0
|
|
|
|
|
|
$position = index($field, "list_"); |
241
|
0
|
0
|
|
|
|
|
if ($position == 0) { |
242
|
0
|
|
|
|
|
|
$str .= "\n"; |
243
|
0
|
|
|
|
|
|
$internal_field = substr($field, $position + 5); |
244
|
0
|
|
|
|
|
|
foreach $elt (@{$self->_getField($field)}) { |
|
0
|
|
|
|
|
|
|
245
|
0
|
|
|
|
|
|
$str .= "\t\t\t<$internal_field>" . $elt->getId . "$internal_field>\n"; |
246
|
|
|
|
|
|
|
} |
247
|
0
|
|
|
|
|
|
$str .= "\t\t"; |
248
|
|
|
|
|
|
|
} else { |
249
|
0
|
|
|
|
|
|
$str .= $self->_getField($field)->[0] ; |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
} |
252
|
0
|
|
|
|
|
|
$str .= "$field>\n"; |
253
|
|
|
|
|
|
|
} else { |
254
|
0
|
0
|
|
|
|
|
if (ref $self->_getField($field) eq "HASH") { |
255
|
0
|
|
|
|
|
|
$str .= "\t\t<$field>"; |
256
|
|
|
|
|
|
|
# $position = index($field, "list_"); |
257
|
|
|
|
|
|
|
# if ($position == 0) { |
258
|
0
|
|
|
|
|
|
$str .= "\n"; |
259
|
0
|
|
|
|
|
|
$internal_field = $self->_getField($field)->{"reference"}; |
260
|
0
|
|
|
|
|
|
foreach $elt (@{$self->_getField($field)->{$self->_getField($field)->{"reference"}}}) { |
|
0
|
|
|
|
|
|
|
261
|
0
|
|
|
|
|
|
$str .= "\t\t\t<$internal_field>" . $elt->getId . "$internal_field>\n"; |
262
|
|
|
|
|
|
|
} |
263
|
0
|
|
|
|
|
|
$str .= "\t\t"; |
264
|
0
|
|
|
|
|
|
$str .= "$field>\n"; |
265
|
|
|
|
|
|
|
} else { |
266
|
0
|
|
|
|
|
|
$str .= "\t\t<$field>" . $self->_xmlencode($self->_getField($field)) . "$field>\n"; |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
} |
271
|
0
|
|
|
|
|
|
$str .= "\t$name>\n"; |
272
|
0
|
|
|
|
|
|
return($str); |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
sub _xmldecode { # to be optimized |
276
|
0
|
|
|
0
|
|
|
my ($self, $string) = @_; |
277
|
|
|
|
|
|
|
|
278
|
0
|
|
|
|
|
|
$string =~ s/&/&/go; |
279
|
0
|
|
|
|
|
|
$string =~ s/"/\"/og; |
280
|
0
|
|
|
|
|
|
$string =~ s/'/\'/og; |
281
|
0
|
|
|
|
|
|
$string =~ s/</
|
282
|
0
|
|
|
|
|
|
$string =~ s/>/>/og; |
283
|
|
|
|
|
|
|
|
284
|
0
|
|
|
|
|
|
return($string); |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub _xmlencode { # to be optimized |
288
|
0
|
|
|
0
|
|
|
my ($self, $string) = @_; |
289
|
|
|
|
|
|
|
|
290
|
0
|
|
|
|
|
|
$string =~ s/&/&/og; |
291
|
0
|
|
|
|
|
|
$string =~ s/\"/"/og; |
292
|
0
|
|
|
|
|
|
$string =~ s/\'/'/og; |
293
|
0
|
|
|
|
|
|
$string =~ s/</og; |
294
|
0
|
|
|
|
|
|
$string =~ s/>/>/og; |
295
|
|
|
|
|
|
|
|
296
|
0
|
|
|
|
|
|
return($string); |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
sub getFrom { |
300
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
301
|
|
|
|
|
|
|
|
302
|
0
|
|
|
|
|
|
return($self->start_token->getFrom); |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
sub getTo { |
306
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
307
|
|
|
|
|
|
|
|
308
|
0
|
|
|
|
|
|
return($self->end_token->getFrom); |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub isBefore { |
312
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
313
|
|
|
|
|
|
|
|
314
|
0
|
0
|
|
|
|
|
if ($self->getTo < $element->getFrom) { |
315
|
0
|
|
|
|
|
|
return(1); |
316
|
|
|
|
|
|
|
} |
317
|
0
|
|
|
|
|
|
return(0); |
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
sub isAfter { |
321
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
322
|
|
|
|
|
|
|
|
323
|
0
|
0
|
|
|
|
|
if ($element->getTo < $self->getFrom) { |
324
|
0
|
|
|
|
|
|
return(1); |
325
|
|
|
|
|
|
|
} |
326
|
0
|
|
|
|
|
|
return(0); |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub contains { |
331
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
# warn "------------------------------------------------------------------------\n"; |
334
|
|
|
|
|
|
|
# warn $element->getForm . "\n"; |
335
|
0
|
|
|
|
|
|
my $offset_start; |
336
|
|
|
|
|
|
|
my $offset_end; |
337
|
0
|
0
|
|
|
|
|
if (ref($self) eq "Lingua::Ogmios::Annotations::Token") { |
338
|
0
|
|
|
|
|
|
$offset_start = $self->getFrom; |
339
|
0
|
|
|
|
|
|
$offset_end = $self->getTo; |
340
|
|
|
|
|
|
|
} else { |
341
|
0
|
|
|
|
|
|
$offset_start = $element->start_token->getFrom; |
342
|
0
|
|
|
|
|
|
$offset_end = $element->end_token->getTo; |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
# warn "\t$offset\n\n"; |
345
|
|
|
|
|
|
|
|
346
|
0
|
0
|
0
|
|
|
|
if (($self->start_token->getFrom <= $offset_start) && |
347
|
|
|
|
|
|
|
($offset_end <= $self->end_token->getTo)) { |
348
|
|
|
|
|
|
|
# warn "OK\n"; |
349
|
0
|
|
|
|
|
|
return(1); |
350
|
|
|
|
|
|
|
} |
351
|
0
|
|
|
|
|
|
return(0); |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
1; |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
__END__ |