| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Treex::PML::Schema::Choice; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
21
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
30
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
|
8
|
1
|
|
|
1
|
|
29
|
$VERSION='2.22'; # version template |
|
9
|
|
|
|
|
|
|
} |
|
10
|
1
|
|
|
1
|
|
4
|
no warnings 'uninitialized'; |
|
|
1
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
30
|
|
|
11
|
1
|
|
|
1
|
|
2
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
41
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use Treex::PML::Schema::Constants; |
|
|
1
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
95
|
|
|
13
|
1
|
|
|
1
|
|
4
|
use base qw( Treex::PML::Schema::Decl ); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
366
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Treex::PML::Schema::Choice - implements declaration of an enumerated |
|
18
|
|
|
|
|
|
|
type (choice). |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 INHERITANCE |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This class inherits from L. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 METHODS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
See the super-class for the complete list. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over 3 |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item $decl->is_atomic () |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Returns 1. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item $decl->get_decl_type () |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Returns the constant PML_CHOICE_DECL. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item $decl->get_decl_type_str () |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Returns the string 'choice'. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item $decl->get_values () |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Return list of possible values. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item $decl->set_values (\@values) |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Set possible values. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item $decl->get_content_decl () |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Returns undef. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item $decl->validate_object($object) |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
See C in L. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
0
|
1
|
|
sub is_atomic { 1 } |
|
63
|
0
|
|
|
0
|
1
|
|
sub get_decl_type { return PML_CHOICE_DECL; } |
|
64
|
0
|
|
|
0
|
1
|
|
sub get_decl_type_str { return 'choice'; } |
|
65
|
0
|
|
|
0
|
1
|
|
sub get_content_decl { return(undef); } |
|
66
|
0
|
|
|
0
|
1
|
|
sub get_values { return @{ $_[0]->{values} }; } |
|
|
0
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub set_values { |
|
68
|
0
|
|
|
0
|
1
|
|
my ($self,$values) = @_; |
|
69
|
0
|
0
|
|
|
|
|
croak(__PACKAGE__."::set_values : argument is not an array reference\n") unless ref($values) eq 'ARRAY'; |
|
70
|
0
|
|
|
|
|
|
@{ $self->{values} }=@$values; |
|
|
0
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
sub init { |
|
73
|
0
|
|
|
0
|
0
|
|
my ($self,$opts)=@_; |
|
74
|
0
|
|
|
|
|
|
$self->{-parent}{-decl} = 'choice'; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
sub post_process { |
|
77
|
0
|
|
|
0
|
0
|
|
my ($choice,$opts)=@_; |
|
78
|
0
|
|
|
|
|
|
$choice->{values} = delete $choice->{value}; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub validate_object { |
|
82
|
0
|
|
|
0
|
1
|
|
my ($self, $object, $opts) = @_; |
|
83
|
0
|
|
|
|
|
|
my $ok = 0; |
|
84
|
0
|
|
|
|
|
|
my $values = $self->{values}; |
|
85
|
0
|
0
|
|
|
|
|
if ($values) { |
|
86
|
0
|
|
|
|
|
|
foreach (@{$values}) { |
|
|
0
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
if ($_ eq $object) { |
|
88
|
0
|
|
|
|
|
|
$ok = 1; |
|
89
|
0
|
|
|
|
|
|
last; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
0
|
0
|
0
|
|
|
|
if (!$ok and ref($opts) and ref($opts->{log})) { |
|
|
|
|
0
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $path = $opts->{path}; |
|
95
|
0
|
|
|
|
|
|
my $tag = $opts->{tag}; |
|
96
|
0
|
0
|
|
|
|
|
$path.="/".$tag if $tag ne q{}; |
|
97
|
0
|
|
|
|
|
|
push @{$opts->{log}}, "$path: Invalid value: '$object'"; |
|
|
0
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
|
99
|
0
|
|
|
|
|
|
return $ok; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub serialize_get_children { |
|
103
|
0
|
|
|
0
|
0
|
|
my ($choice,$opts)=@_; |
|
104
|
0
|
|
|
|
|
|
return map ['value',$_],@{$choice->{values}}; |
|
|
0
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
|
109
|
|
|
|
|
|
|
__END__ |