| 1 | |||||||||||||
| 2 | ### | ||||||||||||
| 3 | # CSS::SAC::Selector::Element - SAC ElementSelector | ||||||||||||
| 4 | # Robin Berjon <robin@knowscape.com> | ||||||||||||
| 5 | # 24/02/2001 | ||||||||||||
| 6 | ### | ||||||||||||
| 7 | |||||||||||||
| 8 | package CSS::SAC::Selector::Element; | ||||||||||||
| 9 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ▶ | use vars qw($VERSION); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 2 | ▶ | $VERSION = $CSS::SAC::VERSION || '0.03'; | ||||||||||
|
Condition50%1/2
$CSS::SAC::VERSION || '0.03'
MC/DC0%0/1
$CSS::SAC::VERSION || '0.03'
$CSS::SAC::VERSION
Truth table50%1/2
A
A= $CSS::SAC::VERSION
| |||||||||||||
| 12 | |||||||||||||
| 13 | 2 | ▶ | use base qw(CSS::SAC::Selector::Simple); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | |||||||||||||
| 16 | #---------------------------------------------------------------------# | ||||||||||||
| 17 | # build the fields for an array based object | ||||||||||||
| 18 | #---------------------------------------------------------------------# | ||||||||||||
| 19 | 2 | ▶ | use Class::ArrayObjects extend => { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | class => 'CSS::SAC::Selector::Simple', | ||||||||||||
| 21 | with => [qw( | ||||||||||||
| 22 | _local_name_ | ||||||||||||
| 23 | _ns_uri_ | ||||||||||||
| 24 | )], | ||||||||||||
| 25 | 2 | }; | |||||||||||
| 26 | #---------------------------------------------------------------------# | ||||||||||||
| 27 | |||||||||||||
| 28 | |||||||||||||
| 29 | |||||||||||||
| 30 | |||||||||||||
| 31 | ### Constructor ####################################################### | ||||||||||||
| 32 | # # | ||||||||||||
| 33 | # # | ||||||||||||
| 34 | |||||||||||||
| 35 | |||||||||||||
| 36 | #---------------------------------------------------------------------# | ||||||||||||
| 37 | # CSS::SAC::Selector::Element->new($type,$ns_uri,$local_name) | ||||||||||||
| 38 | # creates a new sac ElementSelector object | ||||||||||||
| 39 | #---------------------------------------------------------------------# | ||||||||||||
| 40 | 50 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 41 | 50 | ▶ | my $class = ref($_[0])?ref(shift):shift; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | 50 | my $type = shift; | |||||||||||
| 43 | 50 | my $ns_uri = shift; | |||||||||||
| 44 | 50 | my $local_name = shift; | |||||||||||
| 45 | |||||||||||||
| 46 | # create a selector | ||||||||||||
| 47 | 50 | my $esel = $class->SUPER::new($type); | |||||||||||
| 48 | |||||||||||||
| 49 | # add our fields | ||||||||||||
| 50 | 50 | ▶ | $esel->[_local_name_] = $local_name if $local_name; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | 50 | ▶ | $esel->[_ns_uri_] = $ns_uri if defined $ns_uri; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | |||||||||||||
| 53 | 50 | return $esel; | |||||||||||
| 54 | } | ||||||||||||
| 55 | #---------------------------------------------------------------------# | ||||||||||||
| 56 | |||||||||||||
| 57 | |||||||||||||
| 58 | # # | ||||||||||||
| 59 | # # | ||||||||||||
| 60 | ### Constructor ####################################################### | ||||||||||||
| 61 | |||||||||||||
| 62 | |||||||||||||
| 63 | |||||||||||||
| 64 | ### Accessors ######################################################### | ||||||||||||
| 65 | # # | ||||||||||||
| 66 | # # | ||||||||||||
| 67 | |||||||||||||
| 68 | 2 | *CSS::SAC::Selector::Element::getLocalName = \&LocalName; | |||||||||||
| 69 | 2 | *CSS::SAC::Selector::Element::getNamespaceURI = \&NamespaceURI; | |||||||||||
| 70 | |||||||||||||
| 71 | #---------------------------------------------------------------------# | ||||||||||||
| 72 | # my $lname = $esel->LocalName() | ||||||||||||
| 73 | # $esel->LocalName($lname) | ||||||||||||
| 74 | # get/set the selector's local name | ||||||||||||
| 75 | #---------------------------------------------------------------------# | ||||||||||||
| 76 | 50 | ▶ | sub LocalName { | ||||||||||
|
Subroutine
LocalName: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 77 | 50 | ▶ | (@_==2) ? $_[0]->[_local_name_] = $_[1] : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 78 | $_[0]->[_local_name_]; | ||||||||||||
| 79 | } | ||||||||||||
| 80 | #---------------------------------------------------------------------# | ||||||||||||
| 81 | |||||||||||||
| 82 | |||||||||||||
| 83 | #---------------------------------------------------------------------# | ||||||||||||
| 84 | # my $ns = $esel->NamespaceURI() | ||||||||||||
| 85 | # $esel->NamespaceURI($ns) | ||||||||||||
| 86 | # get/set the selector's ns | ||||||||||||
| 87 | #---------------------------------------------------------------------# | ||||||||||||
| 88 | 48 | ▶ | sub NamespaceURI { | ||||||||||
|
Subroutine
NamespaceURI: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 89 | 48 | ▶ | (@_==2) ? $_[0]->[_ns_uri_] = $_[1] : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 90 | $_[0]->[_ns_uri_]; | ||||||||||||
| 91 | } | ||||||||||||
| 92 | #---------------------------------------------------------------------# | ||||||||||||
| 93 | |||||||||||||
| 94 | |||||||||||||
| 95 | # # | ||||||||||||
| 96 | # # | ||||||||||||
| 97 | ### Accessors ######################################################### | ||||||||||||
| 98 | |||||||||||||
| 99 | |||||||||||||
| 100 | |||||||||||||
| 101 | 2 | 1; | |||||||||||
| 102 | |||||||||||||
| 103 | =pod | ||||||||||||
| 104 | |||||||||||||
| 105 | =head1 NAME | ||||||||||||
| 106 | |||||||||||||
| 107 | CSS::SAC::Selector::Element - SAC ElementSelector | ||||||||||||
| 108 | |||||||||||||
| 109 | =head1 SYNOPSIS | ||||||||||||
| 110 | |||||||||||||
| 111 | see CSS::SAC::Selector | ||||||||||||
| 112 | |||||||||||||
| 113 | =head1 DESCRIPTION | ||||||||||||
| 114 | |||||||||||||
| 115 | This is a subclass of CSS::SAC::Selector::Simple, look there for more | ||||||||||||
| 116 | documentation. This class adds the following methods (which also exist | ||||||||||||
| 117 | in spec style, simply prepend them with 'get'): | ||||||||||||
| 118 | |||||||||||||
| 119 | =head1 METHODS | ||||||||||||
| 120 | |||||||||||||
| 121 | =over | ||||||||||||
| 122 | |||||||||||||
| 123 | =item * CSS::SAC::Selector::Element->new($type,$local_name,$ns_uri) | ||||||||||||
| 124 | =item * $esel->new($type,$local_name,$ns_uri) | ||||||||||||
| 125 | |||||||||||||
| 126 | Creates a new element selector. | ||||||||||||
| 127 | |||||||||||||
| 128 | =item * $esel->LocalName([$lname]) | ||||||||||||
| 129 | |||||||||||||
| 130 | get/set the selector's local name | ||||||||||||
| 131 | |||||||||||||
| 132 | =item * $esel->NamespaceURI([$ns]) | ||||||||||||
| 133 | |||||||||||||
| 134 | get/set the selector's ns | ||||||||||||
| 135 | |||||||||||||
| 136 | =back | ||||||||||||
| 137 | |||||||||||||
| 138 | =head1 AUTHOR | ||||||||||||
| 139 | |||||||||||||
| 140 | Robin Berjon <robin@knowscape.com> | ||||||||||||
| 141 | |||||||||||||
| 142 | This module is licensed under the same terms as Perl itself. | ||||||||||||
| 143 | |||||||||||||
| 144 | =cut | ||||||||||||
| 145 | |||||||||||||
| 146 | |||||||||||||