line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Ogmios::Annotations::Element; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
76
|
use strict; |
|
16
|
|
|
|
|
26
|
|
|
16
|
|
|
|
|
464
|
|
4
|
16
|
|
|
16
|
|
78
|
use warnings; |
|
16
|
|
|
|
|
27
|
|
|
16
|
|
|
|
|
45703
|
|
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
|
|
|
|
|
|
|
my $element = { |
16
|
0
|
|
|
|
|
|
'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, $fh) = @_; |
111
|
0
|
0
|
|
|
|
|
if (!defined $fh) { |
112
|
0
|
|
|
|
|
|
$fh = \*STDERR |
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
|
|
|
my $field; |
115
|
0
|
|
|
|
|
|
foreach $field (keys %$self) { |
116
|
0
|
0
|
|
|
|
|
if (defined $self->{$field}) { |
117
|
0
|
|
|
|
|
|
print "$field => " . $self->{$field} . "\n"; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
0
|
|
|
|
|
|
return(0); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub printXML { |
125
|
0
|
|
|
0
|
0
|
|
my ($self, $name, $order) = @_; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
print $self->XMLout($name, $order); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub _XMLoutField { |
131
|
0
|
|
|
0
|
|
|
my ($self, $field, $field_content, $shift) = @_; |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
my $str; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $elt; |
136
|
0
|
|
|
|
|
|
my $internal_field; |
137
|
0
|
|
|
|
|
|
my $position; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
0
|
0
|
|
|
|
|
if (!defined($shift)) { |
141
|
0
|
|
|
|
|
|
$shift = "\t\t"; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# warn "$field - " . ref($field_content) . "\n"; |
145
|
0
|
0
|
|
|
|
|
if (ref($field_content) eq "ARRAY") { |
146
|
0
|
|
|
|
|
|
$position = index($field, "list_"); |
147
|
0
|
0
|
|
|
|
|
if ($position == 0) { |
148
|
0
|
|
|
|
|
|
$str .= "$shift<$field>\n"; |
149
|
0
|
|
|
|
|
|
$internal_field = substr($field, $position + 5); |
150
|
0
|
|
|
|
|
|
foreach $elt (@{$field_content}) { |
|
0
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($internal_field, $elt, "$shift\t"); |
152
|
|
|
|
|
|
|
} |
153
|
0
|
|
|
|
|
|
$str .= "$shift$field>\n"; |
154
|
|
|
|
|
|
|
} else { |
155
|
0
|
|
|
|
|
|
foreach $elt (@{$field_content}) { |
|
0
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($field, $elt, "$shift"); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
0
|
0
|
|
|
|
|
if (ref($field_content) eq "HASH") { |
162
|
0
|
|
|
|
|
|
$str .= "$shift<$field>\n"; |
163
|
0
|
0
|
|
|
|
|
if (defined($internal_field = $field_content->{"reference"})) { |
164
|
0
|
|
|
|
|
|
foreach $elt (@{$field_content->{$field_content->{"reference"}}}) { |
|
0
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($internal_field, $elt, "$shift\t"); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
} else { |
168
|
0
|
0
|
|
|
|
|
if ($field eq "weights") { |
169
|
0
|
|
|
|
|
|
foreach $elt (keys %$field_content) { |
170
|
|
|
|
|
|
|
# if (!defined ($field_content->{$elt})) { |
171
|
|
|
|
|
|
|
# warn "$elt\n"; |
172
|
|
|
|
|
|
|
# } |
173
|
0
|
|
|
|
|
|
$str .= "$shift\t"; |
174
|
0
|
|
|
|
|
|
$str .= $field_content->{$elt} . "\n"; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
} else { |
177
|
0
|
|
|
|
|
|
foreach $elt (keys %$field_content) { |
178
|
|
|
|
|
|
|
# $str .= "$shift<$elt>" . $field_content->{$elt} . "$elt>\n"; |
179
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($elt,$field_content->{$elt},"$shift\t"); #"$shift<$elt>" . $field_content->{$elt} . "$elt>\n"; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
} |
183
|
0
|
|
|
|
|
|
$str .= "$shift$field>\n"; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
0
|
0
|
|
|
|
|
if (index(ref($field_content), "Lingua::Ogmios") > -1) { |
187
|
|
|
|
|
|
|
# warn "$field: " . $field_content->getId . "\n"; |
188
|
0
|
|
|
|
|
|
$str .= "$shift<$field>"; |
189
|
|
|
|
|
|
|
# $str .= $field_content->getId . " = " . $field_content; |
190
|
0
|
|
|
|
|
|
$str .= $field_content->getId; |
191
|
0
|
|
|
|
|
|
$str .= "$field>\n"; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
0
|
0
|
|
|
|
|
if (ref($field_content) eq "") { |
195
|
0
|
|
|
|
|
|
$str .= "$shift<$field>"; |
196
|
0
|
|
|
|
|
|
$str .= $field_content; |
197
|
0
|
|
|
|
|
|
$str .= "$field>\n"; |
198
|
|
|
|
|
|
|
} |
199
|
0
|
|
|
|
|
|
return($str); |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub XMLout { |
203
|
0
|
|
|
0
|
0
|
|
my ($self, $name, $order) = @_; |
204
|
0
|
|
|
|
|
|
my $field; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
my $str; |
207
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
my $elt; |
209
|
0
|
|
|
|
|
|
my $internal_field; |
210
|
0
|
|
|
|
|
|
my $position; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# warn "$name\n"; |
213
|
0
|
|
|
|
|
|
$str = "\t<$name>\n"; |
214
|
0
|
|
|
|
|
|
foreach $field (@$order) { |
215
|
|
|
|
|
|
|
# warn "-->$field\n"; |
216
|
0
|
0
|
|
|
|
|
if (defined $self->_getField($field)) { |
217
|
0
|
0
|
0
|
|
|
|
if ((defined(ref($self->_getField($field)))) && (ref($self->_getField($field)) ne "")) { |
218
|
0
|
|
|
|
|
|
$str .= $self->_XMLoutField($field, $self->_getField($field), "\t\t") ; |
219
|
|
|
|
|
|
|
} else { |
220
|
0
|
|
|
|
|
|
$str .= "\t\t<$field>" . $self->_xmlencode($self->_getField($field)) . "$field>\n"; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
} |
224
|
0
|
|
|
|
|
|
$str .= "\t$name>\n"; |
225
|
0
|
|
|
|
|
|
return($str); |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub XMLout_orig { |
229
|
0
|
|
|
0
|
0
|
|
my ($self, $name, $order) = @_; |
230
|
0
|
|
|
|
|
|
my $field; |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
my $str; |
233
|
|
|
|
|
|
|
|
234
|
0
|
|
|
|
|
|
my $elt; |
235
|
0
|
|
|
|
|
|
my $internal_field; |
236
|
0
|
|
|
|
|
|
my $position; |
237
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
$str = "\t<$name>\n"; |
239
|
0
|
|
|
|
|
|
foreach $field (@$order) { |
240
|
0
|
0
|
|
|
|
|
if (defined $self->_getField($field)) { |
241
|
0
|
0
|
|
|
|
|
if (ref $self->_getField($field) eq "ARRAY") { |
242
|
0
|
|
|
|
|
|
$str .= "\t\t<$field>"; |
243
|
0
|
|
|
|
|
|
$position = index($field, "list_"); |
244
|
0
|
0
|
|
|
|
|
if ($position == 0) { |
245
|
0
|
|
|
|
|
|
$str .= "\n"; |
246
|
0
|
|
|
|
|
|
$internal_field = substr($field, $position + 5); |
247
|
0
|
|
|
|
|
|
foreach $elt (@{$self->_getField($field)}) { |
|
0
|
|
|
|
|
|
|
248
|
0
|
|
|
|
|
|
$str .= "\t\t\t<$internal_field>" . $elt->getId . "$internal_field>\n"; |
249
|
|
|
|
|
|
|
} |
250
|
0
|
|
|
|
|
|
$str .= "\t\t"; |
251
|
|
|
|
|
|
|
} else { |
252
|
0
|
|
|
|
|
|
$str .= $self->_getField($field)->[0] ; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
} |
255
|
0
|
|
|
|
|
|
$str .= "$field>\n"; |
256
|
|
|
|
|
|
|
} else { |
257
|
0
|
0
|
|
|
|
|
if (ref $self->_getField($field) eq "HASH") { |
258
|
0
|
|
|
|
|
|
$str .= "\t\t<$field>"; |
259
|
|
|
|
|
|
|
# $position = index($field, "list_"); |
260
|
|
|
|
|
|
|
# if ($position == 0) { |
261
|
0
|
|
|
|
|
|
$str .= "\n"; |
262
|
0
|
|
|
|
|
|
$internal_field = $self->_getField($field)->{"reference"}; |
263
|
0
|
|
|
|
|
|
foreach $elt (@{$self->_getField($field)->{$self->_getField($field)->{"reference"}}}) { |
|
0
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
$str .= "\t\t\t<$internal_field>" . $elt->getId . "$internal_field>\n"; |
265
|
|
|
|
|
|
|
} |
266
|
0
|
|
|
|
|
|
$str .= "\t\t"; |
267
|
0
|
|
|
|
|
|
$str .= "$field>\n"; |
268
|
|
|
|
|
|
|
} else { |
269
|
0
|
|
|
|
|
|
$str .= "\t\t<$field>" . $self->_xmlencode($self->_getField($field)) . "$field>\n"; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
} |
274
|
0
|
|
|
|
|
|
$str .= "\t$name>\n"; |
275
|
0
|
|
|
|
|
|
return($str); |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub _xmldecode { # to be optimized |
279
|
0
|
|
|
0
|
|
|
my ($self, $string) = @_; |
280
|
|
|
|
|
|
|
|
281
|
0
|
|
|
|
|
|
$string =~ s/&/&/go; |
282
|
0
|
|
|
|
|
|
$string =~ s/"/\"/og; |
283
|
0
|
|
|
|
|
|
$string =~ s/'/\'/og; |
284
|
0
|
|
|
|
|
|
$string =~ s/</
|
285
|
0
|
|
|
|
|
|
$string =~ s/>/>/og; |
286
|
|
|
|
|
|
|
|
287
|
0
|
|
|
|
|
|
return($string); |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub _xmlencode { # to be optimized |
291
|
0
|
|
|
0
|
|
|
my ($self, $string) = @_; |
292
|
|
|
|
|
|
|
|
293
|
0
|
|
|
|
|
|
$string =~ s/&/&/og; |
294
|
0
|
|
|
|
|
|
$string =~ s/\"/"/og; |
295
|
0
|
|
|
|
|
|
$string =~ s/\'/'/og; |
296
|
0
|
|
|
|
|
|
$string =~ s/</og; |
297
|
0
|
|
|
|
|
|
$string =~ s/>/>/og; |
298
|
|
|
|
|
|
|
|
299
|
0
|
|
|
|
|
|
return($string); |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub getFrom { |
303
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
304
|
|
|
|
|
|
|
|
305
|
0
|
|
|
|
|
|
return($self->start_token->getFrom); |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
sub getTo { |
309
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
310
|
|
|
|
|
|
|
|
311
|
0
|
|
|
|
|
|
return($self->end_token->getFrom); |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
sub isBefore { |
315
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
316
|
|
|
|
|
|
|
|
317
|
0
|
0
|
|
|
|
|
if ($self->getTo < $element->getFrom) { |
318
|
0
|
|
|
|
|
|
return(1); |
319
|
|
|
|
|
|
|
} |
320
|
0
|
|
|
|
|
|
return(0); |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
sub isAfter { |
324
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
325
|
|
|
|
|
|
|
|
326
|
0
|
0
|
|
|
|
|
if ($element->getTo < $self->getFrom) { |
327
|
0
|
|
|
|
|
|
return(1); |
328
|
|
|
|
|
|
|
} |
329
|
0
|
|
|
|
|
|
return(0); |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub contains { |
334
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
# warn "------------------------------------------------------------------------\n"; |
337
|
|
|
|
|
|
|
# warn $element->getForm . "\n"; |
338
|
0
|
|
|
|
|
|
my $offset_start; |
339
|
|
|
|
|
|
|
my $offset_end; |
340
|
0
|
0
|
|
|
|
|
if (ref($self) eq "Lingua::Ogmios::Annotations::Token") { |
341
|
0
|
|
|
|
|
|
$offset_start = $self->getFrom; |
342
|
0
|
|
|
|
|
|
$offset_end = $self->getTo; |
343
|
|
|
|
|
|
|
} else { |
344
|
0
|
|
|
|
|
|
$offset_start = $element->start_token->getFrom; |
345
|
0
|
|
|
|
|
|
$offset_end = $element->end_token->getTo; |
346
|
|
|
|
|
|
|
} |
347
|
|
|
|
|
|
|
# warn "\t$offset\n\n"; |
348
|
|
|
|
|
|
|
|
349
|
0
|
0
|
0
|
|
|
|
if (($self->start_token->getFrom <= $offset_start) && |
350
|
|
|
|
|
|
|
($offset_end <= $self->end_token->getTo)) { |
351
|
|
|
|
|
|
|
# warn "OK\n"; |
352
|
0
|
|
|
|
|
|
return(1); |
353
|
|
|
|
|
|
|
} |
354
|
0
|
|
|
|
|
|
return(0); |
355
|
|
|
|
|
|
|
} |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
1; |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
__END__ |