| 1 | package Treex::PML::Schema::Choice; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | $VERSION='2.29'; # version template | |||||||||||||||||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use Treex::PML::Schema::Constants; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use base qw( Treex::PML::Schema::Decl ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 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<Treex::PML::Schema::Decl>. | ||||||||||||||||||||||||||||||||||||||||||
| 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<validate_object()> in L<Treex::PML::Schema>. | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub is_atomic { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_atomic: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 697 | ▶ | sub get_decl_type { return PML_CHOICE_DECL; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_decl_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub get_decl_type_str { return 'choice'; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_decl_type_str: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub get_content_decl { return(undef); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_content_decl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub get_values { return @{ $_[0]->{values} }; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_values: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub set_values { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_values: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my ($self,$values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | croak(__PACKAGE__."::set_values : argument is not an array reference\n") unless ref($values) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | @{ $self->{values} }=@$values; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 84 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 84 | my ($self,$opts)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 84 | $self->{-parent}{-decl} = 'choice'; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 84 | ▶ | sub post_process { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post_process: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 84 | my ($choice,$opts)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 84 | $choice->{values} = delete $choice->{value}; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub validate_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_object: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my ($self, $object, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $ok = 0; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $values = $self->{values}; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ($values) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | foreach (@{$values}) { | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($_ eq $object) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $ok = 1; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if (!$ok and ref($opts) and ref($opts->{log})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $ok and ref $opts and ref $opts->{"log"}
not $ok and ref $opts
MC/DC0%0/3
not $ok and ref $opts and ref $opts->{"log"}
not $ok
ref $opts
ref $opts->{"log"}
Truth table0%0/4
not(A) and B and C
A= not $okB= ref $optsC= ref $opts->{"log"}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $path = $opts->{path}; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $tag = $opts->{tag}; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $path.="/".$tag if $tag ne q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | push @{$opts->{log}}, "$path: Invalid value: '$object'"; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return $ok; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 6 | ▶ | sub serialize_get_children { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize_get_children: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 6 | my ($choice,$opts)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 6 | return map ['value',$_],@{$choice->{values}}; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 109 | __END__ | ||||||||||||||||||||||||||||||||||||||||||