| 1 | package Treex::PML::Schema::Container; | ||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use Treex::PML::Schema::Constants; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 9 | ▶ | use base qw( Treex::PML::Schema::Decl ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 9 | ▶ | use UNIVERSAL::DOES; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 9 | ▶ | use Treex::PML::Factory; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 NAME | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | Treex::PML::Schema::Container - implements declaration of a container. | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 INHERITANCE | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | This class inherits from L<Treex::PML::Schema::Decl>, but provides | ||||||||||||||||||||||||||||
| 25 | several methods which make its interface largely compatible with | ||||||||||||||||||||||||||||
| 26 | the C<Treex::PML::Schema::Struct> class. | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head1 METHODS | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | See the super-class for the complete list. | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =over 3 | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =item $decl->get_decl_type () | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | Returns the constant PML_CONTAINER_DECL. | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =item $decl->get_decl_type_str () | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | Returns the string 'container'. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =item $decl->get_content_decl () | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | Return declaration of the content type. | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =item $decl->is_atomic () | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Returns 0. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =cut | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 510 | ▶ | sub get_decl_type { return PML_CONTAINER_DECL; } | ||||||||||||||||||||||||||
|
Subroutine
get_decl_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub get_decl_type_str { return 'container'; } | ||||||||||||||||||||||||||
|
Subroutine
get_decl_type_str: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub is_atomic { 0 } | ||||||||||||||||||||||||||
|
Subroutine
is_atomic: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 96 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | 96 | my ($self,$opts)=@_; | |||||||||||||||||||||||||||
| 58 | 96 | $self->{-parent}{-decl} = 'container'; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 12 | ▶ | sub serialize_get_children { | ||||||||||||||||||||||||||
|
Subroutine
serialize_get_children: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 12 | my ($self,$opts)=@_; | |||||||||||||||||||||||||||
| 62 | 12 | my @children = $self->SUPER::serialize_get_children($opts); | |||||||||||||||||||||||||||
| 63 | 25 | return ((grep { $_->[0] eq 'attribute' } @children), | |||||||||||||||||||||||||||
| 64 | 12 | (grep { $_->[0] ne 'attribute' } @children)); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =item $decl->get_attributes () | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | Return a list of the associated attribute declarations | ||||||||||||||||||||||||||||
| 70 | (C<Treex::PML::Schema::Attribute>). | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 286 | ▶ | sub get_attributes { | ||||||||||||||||||||||||||
|
Subroutine
get_attributes: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 286 | my $members = $_[0]->{attribute}; | |||||||||||||||||||||||||||
| 76 | 286 | ▶ | return $members ? map { $_->[0] } sort { $a->[1]<=> $b->[1] } map { [ $_, $_->{'-#'} ] } values %$members : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =item $decl->has_attributes () | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Return true if the container declares attributes. | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub has_attributes { | ||||||||||||||||||||||||||
|
Subroutine
has_attributes: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | my $members = $_[0]->{attribute}; | |||||||||||||||||||||||||||
| 87 | 0 | ▶ | return $members ? scalar(%$members) : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =item $decl->get_attribute_names () | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | Return a list of names of attributes associated with the container. | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =cut | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub get_attribute_names { | ||||||||||||||||||||||||||
|
Subroutine
get_attribute_names: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | 0 | my $members = $_[0]->{attribute}; | |||||||||||||||||||||||||||
| 99 | 0 | ▶ | return $members ? map { $_->[0] } sort { $a->[1]<=> $b->[1] } map { [ $_, $members->{$_}->{'-#'} ] } keys %$members : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =item $decl->get_attribute_by_name (name) | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Return the declaration of the attribute with a given name. | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 2 | ▶ | sub get_attribute_by_name { | ||||||||||||||||||||||||||
|
Subroutine
get_attribute_by_name: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | 2 | my ($self, $name) = @_; | |||||||||||||||||||||||||||
| 110 | 2 | my $members = $_[0]->{attribute}; | |||||||||||||||||||||||||||
| 111 | 2 | ▶ | return $members ? $members->{$name} : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =item $decl->find_attributes_by_content_decl (decl) | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | Lookup and return those attribute declarations whose content | ||||||||||||||||||||||||||||
| 117 | declaration is decl. | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub find_attributes_by_content_decl { | ||||||||||||||||||||||||||
|
Subroutine
find_attributes_by_content_decl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | 0 | my ($self, $decl) = @_; | |||||||||||||||||||||||||||
| 123 | 0 | return grep { $decl == $_->get_content_decl } $self->get_attributes; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =item $decl->find_attributes_by_type_name (name) | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | Lookup and return those attribute declarations whose content is | ||||||||||||||||||||||||||||
| 129 | specified via a reference to the named type with a given name. | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =cut | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub find_attributes_by_type_name { | ||||||||||||||||||||||||||
|
Subroutine
find_attributes_by_type_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 134 | 0 | my ($self, $type_name) = @_; | |||||||||||||||||||||||||||
| 135 | # using directly $member->{type} | ||||||||||||||||||||||||||||
| 136 | 0 | return grep { $type_name eq $_->{type} } $self->get_attributes; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =item $decl->find_attributes_by_role (role) | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | Lookup and return declarations of all members with a given role. | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =cut | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub find_attributes_by_role { | ||||||||||||||||||||||||||
|
Subroutine
find_attributes_by_role: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 146 | 0 | my ($self, $role) = @_; | |||||||||||||||||||||||||||
| 147 | # using directly $member->{role} | ||||||||||||||||||||||||||||
| 148 | 0 | return grep { $role eq $_->{role} } $self->get_attributes; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub validate_object { | ||||||||||||||||||||||||||
|
Subroutine
validate_object: not called CC=22 SCAR=62.3
Pod
documented
| |||||||||||||||||||||||||||||
| 152 | 0 | my ($self, $object, $opts) = @_; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | my ($path,$tag,$flags); | |||||||||||||||||||||||||||
| 155 | 0 | my $log = []; | |||||||||||||||||||||||||||
| 156 | 0 | ▶ | if (ref($opts)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 0 | $flags = $opts->{flags}; | |||||||||||||||||||||||||||
| 158 | 0 | $path = $opts->{path}; | |||||||||||||||||||||||||||
| 159 | 0 | $tag = $opts->{tag}; | |||||||||||||||||||||||||||
| 160 | 0 | ▶ | $path.="/".$tag if $tag ne q{}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if (not UNIVERSAL::isa($object,'HASH')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | 0 | push @$log, "$path: Unexpected container object (should be a HASH): $object"; | |||||||||||||||||||||||||||
| 165 | } else { | ||||||||||||||||||||||||||||
| 166 | 0 | my @attributes = $self->get_attributes; | |||||||||||||||||||||||||||
| 167 | 0 | foreach my $attr (@attributes) { | |||||||||||||||||||||||||||
| 168 | 0 | my $name = $attr->get_name; | |||||||||||||||||||||||||||
| 169 | 0 | my $val = $object->{$name}; | |||||||||||||||||||||||||||
| 170 | 0 | my $adecl = $attr->get_content_decl; | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | if ($attr->is_required or $val ne q{}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attr->is_required or $val ne ""
MC/DC0%0/2
$attr->is_required or $val ne ""
$attr->is_required
$val ne ""
Truth table0%0/3
A or B
A= $attr->is_requiredB= $val ne ""
| |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if (ref($val)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 173 | 0 | push @$log, "$path/$name: invalid content for attribute: ".ref($val); | |||||||||||||||||||||||||||
| 174 | } elsif ($adecl) { | ||||||||||||||||||||||||||||
| 175 | 0 | $adecl->validate_object($val, { | |||||||||||||||||||||||||||
| 176 | flags => $flags, | ||||||||||||||||||||||||||||
| 177 | path => $path, | ||||||||||||||||||||||||||||
| 178 | tag => $name, | ||||||||||||||||||||||||||||
| 179 | log => $log }); | ||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | 0 | my $cdecl = $self->get_content_decl; | |||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($cdecl) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 0 | my $content = $object->{'#content'}; | |||||||||||||||||||||||||||
| 186 | 0 | my $skip_content = 0; | |||||||||||||||||||||||||||
| 187 | 0 | ▶ | if ($self->get_role eq '#NODE' and !($flags & PML_VALIDATE_NO_TREES)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_role eq "#NODE" and not $flags & 1
MC/DC0%0/2
$self->get_role eq "#NODE" and not $flags & 1
$self->get_role eq "#NODE"
not $flags & 1
Truth table0%0/3
A and not(B)
A= $self->get_role eq "#NODE"B= not $flags & 1
| |||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if (not UNIVERSAL::DOES::does($object,'Treex::PML::Node')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 0 | push @$log,"$path: container declared as #NODE should be a Treex::PML::Node object: $object"; | |||||||||||||||||||||||||||
| 190 | } else { | ||||||||||||||||||||||||||||
| 191 | 0 | my $cdecl_is = $cdecl->get_decl_type; | |||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ($cdecl->get_role eq '#CHILDNODES') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if ($content ne q{}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 0 | push @$log, "$path: #NODE container containing a #CHILDNODES should have empty #content: $content"; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if ($flags & PML_VALIDATE_NO_CHILDNODES) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 197 | 0 | $skip_content = 1; | |||||||||||||||||||||||||||
| 198 | } elsif ($cdecl_is == PML_SEQUENCE_DECL) { | ||||||||||||||||||||||||||||
| 199 | 0 | $content = Treex::PML::Factory->createSeq([map { Treex::PML::Seq::Element->new($_->{'#name'},$_) } $object->children]); | |||||||||||||||||||||||||||
| 200 | } elsif ($cdecl_is == PML_LIST_DECL) { | ||||||||||||||||||||||||||||
| 201 | 0 | $content = Treex::PML::Factory->createList([$object->children],1); | |||||||||||||||||||||||||||
| 202 | } else { | ||||||||||||||||||||||||||||
| 203 | 0 | push @$log, "$path: #CHILDNODES should be either a list or sequence"; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | 0 | ▶ | unless ($skip_content) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 0 | $cdecl->validate_object($content,{ | |||||||||||||||||||||||||||
| 210 | flags => $flags, | ||||||||||||||||||||||||||||
| 211 | path => $path, | ||||||||||||||||||||||||||||
| 212 | tag => '#content', | ||||||||||||||||||||||||||||
| 213 | log =>$log | ||||||||||||||||||||||||||||
| 214 | }); | ||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ($opts and ref($opts->{log})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts and ref $opts->{"log"}
MC/DC0%0/2
$opts and ref $opts->{"log"}
$opts
ref $opts->{"log"}
Truth table0%0/3
A and B
A= $optsB= ref $opts->{"log"}
| |||||||||||||||||||||||||||||
| 219 | 0 | push @{$opts->{log}}, @$log; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | 0 | ▶ | return @$log ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | =back | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | =head1 COMPATIBILITY METHODS | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | =over 3 | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | =item $decl->get_members () | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | Return declarations of all associated attributes and of the content | ||||||||||||||||||||||||||||
| 233 | type. | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | =cut | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 138 | ▶ | sub get_members { | ||||||||||||||||||||||||||
|
Subroutine
get_members: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 238 | 138 | my $self = shift; | |||||||||||||||||||||||||||
| 239 | 138 | return ($self->get_attributes, $self->get_content_decl); | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | =item $decl->get_member_by_name (name) | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | If name is equal to '#content', return the content type declaration, | ||||||||||||||||||||||||||||
| 245 | otherwise acts like C<get_attribute_by_name>. | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | =cut | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 2 | ▶ | sub get_member_by_name { | ||||||||||||||||||||||||||
|
Subroutine
get_member_by_name: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 250 | 2 | my ($self, $name) = @_; | |||||||||||||||||||||||||||
| 251 | 2 | ▶ | if ($name eq '#content') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | 0 | return $self->get_content_decl | |||||||||||||||||||||||||||
| 253 | } else { | ||||||||||||||||||||||||||||
| 254 | 2 | return $self->get_attribute_by_name($name); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | =item $decl->get_member_names () | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | Return a list of all attribute names plus the string '#content'. | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | =cut | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub get_member_names { | ||||||||||||||||||||||||||
|
Subroutine
get_member_names: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 265 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 266 | 0 | ▶ | return ($self->get_attribute_names, ($self->get_content_decl ? ('#content') : ())) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | =item $decl->find_members_by_content_decl (decl) | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | Lookup and return those member (attribute or content) declarations | ||||||||||||||||||||||||||||
| 273 | whose content declaration is decl. | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | =item $decl->find_members_by_type_name (name) | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | Lookup and return those member (attribute or content) declarations | ||||||||||||||||||||||||||||
| 278 | whose content is specified via a reference to the named type with a | ||||||||||||||||||||||||||||
| 279 | given name. | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | =item $decl->find_members_by_role (role) | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | Lookup and return declarations of all members (attribute or content) | ||||||||||||||||||||||||||||
| 284 | with a given role. | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | =cut | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 9 | *find_members_by_content_decl = \&Treex::PML::Schema::Struct::find_members_by_content_decl; | |||||||||||||||||||||||||||
| 289 | 9 | *find_members_by_type_name = \&Treex::PML::Schema::Struct::find_members_by_type_name; | |||||||||||||||||||||||||||
| 290 | 9 | *find_members_by_role = \&Treex::PML::Schema::Struct::find_members_by_role; | |||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =back | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | =cut | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 9 | 1; | |||||||||||||||||||||||||||
| 297 | __END__ | ||||||||||||||||||||||||||||