File Coverage

blib/lib/XML/Stream/XPath/Value.pm
Criterion Covered Total %
statement 56 69 81.1
branch 9 12 75.0
condition n/a
subroutine 14 16 87.5
pod 0 12 0.0
total 79 109 72.4


line stmt bran cond sub pod time code
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     12   180 use 5.008;
  12         33  
  12         407  
26 12     12   51 use strict;
  12         15  
  12         293  
27 12     12   45 use warnings;
  12         21  
  12         315  
28 12     12   46 use vars qw( $VERSION );
  12         19  
  12         6782  
29              
30             $VERSION = "1.23_07";
31              
32             sub new
33             {
34 577     577 0 545 my $proto = shift;
35 577         567 my $self = { };
36              
37 577         957 bless($self,$proto);
38              
39 577         871 $self->setList(@_);
40 577         788 $self->setValues();
41 577         736 $self->setAttribs();
42 577         770 $self->setValid(0);
43 577         733 $self->in_context(0);
44              
45 577         918 return $self;
46             }
47              
48              
49             sub setList
50             {
51 1273     1273 0 1085 my $self = shift;
52 1273         1389 my (@values) = @_;
53 1273         2243 $self->{LIST} = \@values;
54             }
55              
56              
57             sub getList
58             {
59 736     736 0 617 my $self = shift;
60 736 100       515 return unless ($#{$self->{LIST}} > -1);
  736         1580  
61 720         560 return @{$self->{LIST}};
  720         1421  
62             }
63              
64              
65             sub getFirstElem
66             {
67 0     0 0 0 my $self = shift;
68 0 0       0 return unless ($#{$self->{LIST}} > -1);
  0         0  
69 0         0 return $self->{LIST}->[0];
70             }
71              
72              
73             sub setValues
74             {
75 796     796 0 693 my $self = shift;
76 796         706 my (@values) = @_;
77 796         1133 $self->{VALUES} = \@values;
78             }
79              
80              
81             sub getValues
82             {
83 46     46 0 45 my $self = shift;
84 46 100       45 return unless ($#{$self->{VALUES}} > -1);
  46         134  
85 19 50       46 return $self->{VALUES}->[0] if !wantarray;
86 19         18 return @{$self->{VALUES}};
  19         55  
87             }
88              
89              
90             sub setAttribs
91             {
92 775     775 0 615 my $self = shift;
93 775         799 my (%attribs) = @_;
94 775         1068 $self->{ATTRIBS} = \%attribs;
95             }
96              
97              
98             sub getAttribs
99             {
100 48     48 0 50 my $self = shift;
101 48 100       43 return unless (scalar(keys(%{$self->{ATTRIBS}})) > 0);
  48         243  
102 2         2 return %{$self->{ATTRIBS}};
  2         8  
103             }
104              
105              
106             sub setValid
107             {
108 700     700 0 565 my $self = shift;
109 700         521 my $valid = shift;
110 700         860 $self->{VALID} = $valid;
111             }
112              
113              
114             sub check
115             {
116 123     123 0 127 my $self = shift;
117 123         326 return $self->{VALID};
118             }
119              
120              
121             sub in_context
122             {
123 1139     1139 0 962 my $self = shift;
124 1139         853 my $in_context = shift;
125              
126 1139 100       1569 if (defined($in_context))
127             {
128 1031         1043 $self->{INCONTEXT} = $in_context;
129             }
130 1139         1303 return $self->{INCONTEXT};
131             }
132              
133              
134             sub display
135             {
136 0     0 0   my $self = shift;
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}})
  0            
145             {
146 0           print "VALUE: ",$elem->GetXML(),"\n";
147             }
148 0           print "VALUE: )\n";
149             }
150 0           print "VALUE: values(",join(",",@{$self->{VALUES}}),")\n";
  0            
151             }
152              
153             1;
154