blib/lib/XML/Stream/XPath/Value.pm

filter: Statementstmt 81.4% 57 / 70 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 14 / 16 Podpod 0.0% 0 / 12 totaltotal 72.7% 80 / 110 CC 8 SCAR 8.7
CC
8
Cov
80%
getFirstElem
6.0
display
6.0
getValues
3.0
CRAP 2.4
« blib/lib/XML/Stream/Namespace.pm ↑ Summary blib/lib/XML/Stream/XPath.pm »
1 ##############################################################################
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Library General Public
5 # License as published by the Free Software Foundation; either
6 # version 2 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Library General Public License for more details.
12 #
13 # You should have received a copy of the GNU Library General Public
14 # License along with this library; if not, write to the
15 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 # Boston, MA 02111-1307, USA.
17 #
18 # Jabber
19 # Copyright (C) 1998-2004 Jabber Software Foundation http://jabber.org/
20 #
21 ##############################################################################
22  
23 package XML::Stream::XPath::Value;
24  
25 12 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 12 ▶use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 12 $VERSION = "1.23_06";
31  
32 sub new
33 {
34 535 ▶ my $proto = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
35 535 my $self = { };
36  
37 535 bless($self,$proto);
38  
39 535 $self->setList(@_);
40 535 $self->setValues();
41 535 $self->setAttribs();
42 535 $self->setValid(0);
43 535 $self->in_context(0);
44  
45 535 return $self;
46 }
47  
48  
49 sub setList
50 {
51 1166 ▶ my $self = shift;
Subroutine setList: called CC=1 SCAR=0.0
Pod undocumented
52 1166 my (@values) = @_;
53 1166 $self->{LIST} = \@values;
54 }
55  
56  
57 sub getList
58 {
59 662 ▶ my $self = shift;
Subroutine getList: called CC=2 SCAR=6.9
Pod undocumented
60 662 ▶ return unless ($#{$self->{LIST}} > -1);
Branch: 1 branch
BranchTrueFalseTotal
unless $#{$$self{"LIST"};} > -1 16 646 662
61 646 return @{$self->{LIST}};
62 }
63  
64  
65 sub getFirstElem
66 {
67 0 ▶ my $self = shift;
Subroutine getFirstElem: not called CC=2 SCAR=17.9
Pod undocumented
68 0 ▶ return unless ($#{$self->{LIST}} > -1);
Branch: 1 branch
BranchTrueFalseTotal
unless $#{$$self{"LIST"};} > -1 0 0 0
69 0 return $self->{LIST}->[0];
70 }
71  
72  
73 sub setValues
74 {
75 733 ▶ my $self = shift;
Subroutine setValues: called CC=1 SCAR=0.0
Pod undocumented
76 733 my (@values) = @_;
77 733 $self->{VALUES} = \@values;
78 }
79  
80  
81 sub getValues
82 {
83 32 ▶ my $self = shift;
Subroutine getValues: called CC=3 SCAR=11.0
Pod undocumented
84 32 ▶ return unless ($#{$self->{VALUES}} > -1);
Branch: 1 branch
BranchTrueFalseTotal
unless $#{$$self{"VALUES"};} > -1 22 10 32
85 10 ▶ return $self->{VALUES}->[0] if !wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 10 10
86 10 return @{$self->{VALUES}};
87 }
88  
89  
90 sub setAttribs
91 {
92 721 ▶ my $self = shift;
Subroutine setAttribs: called CC=1 SCAR=0.0
Pod undocumented
93 721 my (%attribs) = @_;
94 721 $self->{ATTRIBS} = \%attribs;
95 }
96  
97  
98 sub getAttribs
99 {
100 34 ▶ my $self = shift;
Subroutine getAttribs: called CC=2 SCAR=6.9
Pod undocumented
101 34 ▶ return unless (scalar(keys(%{$self->{ATTRIBS}})) > 0);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar keys %{$$self{"ATTRIBS"};} > 0 32 2 34
102 2 return %{$self->{ATTRIBS}};
103 }
104  
105  
106 sub setValid
107 {
108 640 ▶ my $self = shift;
Subroutine setValid: called CC=1 SCAR=0.0
Pod undocumented
109 640 my $valid = shift;
110 640 $self->{VALID} = $valid;
111 }
112  
113  
114 sub check
115 {
116 105 ▶ my $self = shift;
Subroutine check: called CC=1 SCAR=0.0
Pod undocumented
117 105 return $self->{VALID};
118 }
119  
120  
121 sub in_context
122 {
123 1052 ▶ my $self = shift;
Subroutine in_context: called CC=2 SCAR=6.9
Pod undocumented
124 1052 my $in_context = shift;
125  
126 1052 ▶ if (defined($in_context))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $in_context) 965 87 1052
127 {
128 965 $self->{INCONTEXT} = $in_context;
129 }
130 1052 return $self->{INCONTEXT};
131 }
132  
133  
134 sub display
135 {
136 0 ▶ my $self = shift;
Subroutine display: not called CC=2 SCAR=17.9
Pod undocumented
137 0 if (0)
138 {
139 print "VALUE: list(",join(",",@{$self->{LIST}}),")\n";
140 }
141 else
142 {
143 0 print "VALUE: list(\n";
144 0 foreach my $elem (@{$self->{LIST}})
145 {
146 0 print "VALUE: ",$elem->GetXML(),"\n";
147 }
148 0 print "VALUE: )\n";
149 }
150 0 print "VALUE: values(",join(",",@{$self->{VALUES}}),")\n";
151 }
152  
153 12 1;
154  
« blib/lib/XML/Stream/Namespace.pm ↑ Summary blib/lib/XML/Stream/XPath.pm »