| 1 | |||||||||||||
| 2 | ### | ||||||||||||
| 3 | # CSS::SAC::Condition::Attribute - SAC AttributeConditions | ||||||||||||
| 4 | # Robin Berjon <robin@knowscape.com> | ||||||||||||
| 5 | # 24/02/2001 | ||||||||||||
| 6 | ### | ||||||||||||
| 7 | |||||||||||||
| 8 | package CSS::SAC::Condition::Attribute; | ||||||||||||
| 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::Condition); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | #---------------------------------------------------------------------# | ||||||||||||
| 16 | # build the fields for an array based object | ||||||||||||
| 17 | #---------------------------------------------------------------------# | ||||||||||||
| 18 | 2 | ▶ | use Class::ArrayObjects extend => { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | class => 'CSS::SAC::Condition', | ||||||||||||
| 20 | with => [qw( | ||||||||||||
| 21 | _local_name_ | ||||||||||||
| 22 | _value_ | ||||||||||||
| 23 | _ns_uri_ | ||||||||||||
| 24 | _specified_ | ||||||||||||
| 25 | )], | ||||||||||||
| 26 | 2 | }; | |||||||||||
| 27 | #---------------------------------------------------------------------# | ||||||||||||
| 28 | |||||||||||||
| 29 | |||||||||||||
| 30 | |||||||||||||
| 31 | |||||||||||||
| 32 | ### Constructor ####################################################### | ||||||||||||
| 33 | # # | ||||||||||||
| 34 | # # | ||||||||||||
| 35 | |||||||||||||
| 36 | |||||||||||||
| 37 | #---------------------------------------------------------------------# | ||||||||||||
| 38 | # CSS::SAC::Condition::Attribute->new($type,$lname,$ns,$specified,$value) | ||||||||||||
| 39 | # creates a new sac AttributeCondition object | ||||||||||||
| 40 | #---------------------------------------------------------------------# | ||||||||||||
| 41 | 15 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||
| 42 | 15 | ▶ | my $class = ref($_[0])?ref(shift):shift; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 15 | my $type = shift; # should be one of the attribute conditions | |||||||||||
| 44 | 15 | my $local_name = shift; | |||||||||||
| 45 | 15 | my $ns_uri = shift; | |||||||||||
| 46 | 15 | my $specified = shift; | |||||||||||
| 47 | 15 | my $value = shift; | |||||||||||
| 48 | |||||||||||||
| 49 | # create a condition | ||||||||||||
| 50 | 15 | my $acond = $class->SUPER::new($type); | |||||||||||
| 51 | |||||||||||||
| 52 | # add our fields | ||||||||||||
| 53 | 15 | ▶ | $acond->[_local_name_] = $local_name if $local_name; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 54 | 15 | ▶ | $acond->[_value_] = $value if defined $value; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 55 | 15 | ▶ | $acond->[_ns_uri_] = $ns_uri if defined $ns_uri; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 56 | 15 | ▶ | $acond->[_specified_] = $specified if $specified; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 57 | |||||||||||||
| 58 | 15 | return $acond; | |||||||||||
| 59 | } | ||||||||||||
| 60 | #---------------------------------------------------------------------# | ||||||||||||
| 61 | |||||||||||||
| 62 | |||||||||||||
| 63 | # # | ||||||||||||
| 64 | # # | ||||||||||||
| 65 | ### Constructor ####################################################### | ||||||||||||
| 66 | |||||||||||||
| 67 | |||||||||||||
| 68 | |||||||||||||
| 69 | ### Accessors ######################################################### | ||||||||||||
| 70 | # # | ||||||||||||
| 71 | # # | ||||||||||||
| 72 | |||||||||||||
| 73 | # aliases | ||||||||||||
| 74 | 2 | *CSS::SAC::Condition::Attribute::getLocalName = \&LocalName; | |||||||||||
| 75 | 2 | *CSS::SAC::Condition::Attribute::getNamespaceURI = \&NamespaceURI; | |||||||||||
| 76 | 2 | *CSS::SAC::Condition::Attribute::getValue = \&Value; | |||||||||||
| 77 | 2 | *CSS::SAC::Condition::Attribute::getSpecified = \&Specified; | |||||||||||
| 78 | |||||||||||||
| 79 | |||||||||||||
| 80 | #---------------------------------------------------------------------# | ||||||||||||
| 81 | # my $lname = $cond->LocalName() | ||||||||||||
| 82 | # $cond->LocalName($lname) | ||||||||||||
| 83 | # get/set the local name | ||||||||||||
| 84 | #---------------------------------------------------------------------# | ||||||||||||
| 85 | 9 | ▶ | sub LocalName { | ||||||||||
|
Subroutine
LocalName: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 86 | 9 | ▶ | (@_==2) ? $_[0]->[_local_name_] = $_[1] : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 87 | $_[0]->[_local_name_]; | ||||||||||||
| 88 | } | ||||||||||||
| 89 | #---------------------------------------------------------------------# | ||||||||||||
| 90 | |||||||||||||
| 91 | |||||||||||||
| 92 | #---------------------------------------------------------------------# | ||||||||||||
| 93 | # my $ns = $cond->NamespaceURI() | ||||||||||||
| 94 | # $cond->NamespaceURI($ns) | ||||||||||||
| 95 | # get/set the ns uri | ||||||||||||
| 96 | #---------------------------------------------------------------------# | ||||||||||||
| 97 | 9 | ▶ | sub NamespaceURI { | ||||||||||
|
Subroutine
NamespaceURI: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 98 | 9 | ▶ | (@_==2) ? $_[0]->[_ns_uri_] = $_[1] : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 99 | $_[0]->[_ns_uri_]; | ||||||||||||
| 100 | } | ||||||||||||
| 101 | #---------------------------------------------------------------------# | ||||||||||||
| 102 | |||||||||||||
| 103 | |||||||||||||
| 104 | #---------------------------------------------------------------------# | ||||||||||||
| 105 | # my $value = $cond->Value() | ||||||||||||
| 106 | # $cond->Value($value) | ||||||||||||
| 107 | # get/set the value | ||||||||||||
| 108 | #---------------------------------------------------------------------# | ||||||||||||
| 109 | 12 | ▶ | sub Value { | ||||||||||
|
Subroutine
Value: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 110 | 12 | ▶ | (@_==2) ? $_[0]->[_value_] = $_[1] : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 111 | $_[0]->[_value_]; | ||||||||||||
| 112 | } | ||||||||||||
| 113 | #---------------------------------------------------------------------# | ||||||||||||
| 114 | |||||||||||||
| 115 | |||||||||||||
| 116 | #---------------------------------------------------------------------# | ||||||||||||
| 117 | # my $spec = $cond->Specified() | ||||||||||||
| 118 | # $cond->Specified($spec) | ||||||||||||
| 119 | # get/set the 'specified' state, ie whether a specific value was | ||||||||||||
| 120 | # requested for this attr | ||||||||||||
| 121 | #---------------------------------------------------------------------# | ||||||||||||
| 122 | 9 | ▶ | sub Specified { | ||||||||||
|
Subroutine
Specified: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||
| 123 | 9 | ▶ | (@_==2) ? $_[0]->[_specified_] = $_[1] : | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 124 | $_[0]->[_specified_]; | ||||||||||||
| 125 | } | ||||||||||||
| 126 | #---------------------------------------------------------------------# | ||||||||||||
| 127 | |||||||||||||
| 128 | |||||||||||||
| 129 | |||||||||||||
| 130 | # # | ||||||||||||
| 131 | # # | ||||||||||||
| 132 | ### Accessors ######################################################### | ||||||||||||
| 133 | |||||||||||||
| 134 | |||||||||||||
| 135 | |||||||||||||
| 136 | 2 | 1; | |||||||||||
| 137 | |||||||||||||
| 138 | =pod | ||||||||||||
| 139 | |||||||||||||
| 140 | =head1 NAME | ||||||||||||
| 141 | |||||||||||||
| 142 | CSS::SAC::Condition::Attribute - SAC AttributeConditions | ||||||||||||
| 143 | |||||||||||||
| 144 | =head1 SYNOPSIS | ||||||||||||
| 145 | |||||||||||||
| 146 | see CSS::SAC::Condition | ||||||||||||
| 147 | |||||||||||||
| 148 | =head1 DESCRIPTION | ||||||||||||
| 149 | |||||||||||||
| 150 | This is a subclass of CSS::SAC::Condition, look there for more | ||||||||||||
| 151 | documentation. This class adds the following methods (the spec | ||||||||||||
| 152 | equivalents are available as well, just prepend 'get'): | ||||||||||||
| 153 | |||||||||||||
| 154 | =head1 METHODS | ||||||||||||
| 155 | |||||||||||||
| 156 | =over 4 | ||||||||||||
| 157 | |||||||||||||
| 158 | =item * CSS::SAC::Condition::Attribute->new($type,$lname,$ns,$specified,$value) | ||||||||||||
| 159 | |||||||||||||
| 160 | =item * $cond->new($type,$lname,$ns,$specified,$value) | ||||||||||||
| 161 | |||||||||||||
| 162 | Creates a new attribute condition. | ||||||||||||
| 163 | |||||||||||||
| 164 | =item * $acond->LocalName([$lname]) | ||||||||||||
| 165 | |||||||||||||
| 166 | get/set the local name | ||||||||||||
| 167 | |||||||||||||
| 168 | =item * $acond->NamespaceURI([$ns]) | ||||||||||||
| 169 | |||||||||||||
| 170 | get/set the ns uri | ||||||||||||
| 171 | |||||||||||||
| 172 | =item * $acond->Value([$value]) | ||||||||||||
| 173 | |||||||||||||
| 174 | get/set the value | ||||||||||||
| 175 | |||||||||||||
| 176 | =item * $acond->Specified([$spec]) | ||||||||||||
| 177 | |||||||||||||
| 178 | get/set the 'specified' state, ie whether a specific value was | ||||||||||||
| 179 | requested for this attr | ||||||||||||
| 180 | |||||||||||||
| 181 | =back | ||||||||||||
| 182 | |||||||||||||
| 183 | =head1 AUTHOR | ||||||||||||
| 184 | |||||||||||||
| 185 | Robin Berjon <robin@knowscape.com> | ||||||||||||
| 186 | |||||||||||||
| 187 | This module is licensed under the same terms as Perl itself. | ||||||||||||
| 188 | |||||||||||||
| 189 | =cut | ||||||||||||
| 190 | |||||||||||||
| 191 | |||||||||||||