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 11     11   185 use 5.008;
  11         38  
  11         557  
26 11     11   64 use strict;
  11         26  
  11         323  
27 11     11   55 use warnings;
  11         28  
  11         339  
28 11     11   54 use vars qw( $VERSION );
  11         18  
  11         9052  
29              
30             $VERSION = "1.23_06";
31              
32             sub new
33             {
34 577     577 0 765 my $proto = shift;
35 577         922 my $self = { };
36              
37 577         1405 bless($self,$proto);
38              
39 577         1222 $self->setList(@_);
40 577         1221 $self->setValues();
41 577         1095 $self->setAttribs();
42 577         1136 $self->setValid(0);
43 577         1126 $self->in_context(0);
44              
45 577         1546 return $self;
46             }
47              
48              
49             sub setList
50             {
51 1273     1273 0 1901 my $self = shift;
52 1273         2366 my (@values) = @_;
53 1273         3699 $self->{LIST} = \@values;
54             }
55              
56              
57             sub getList
58             {
59 735     735 0 850 my $self = shift;
60 735 100       801 return unless ($#{$self->{LIST}} > -1);
  735         2340  
61 719         894 return @{$self->{LIST}};
  719         10932  
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 921 my $self = shift;
76 796         1108 my (@values) = @_;
77 796         1864 $self->{VALUES} = \@values;
78             }
79              
80              
81             sub getValues
82             {
83 45     45 0 70 my $self = shift;
84 45 100       61 return unless ($#{$self->{VALUES}} > -1);
  45         185  
85 19 50       66 return $self->{VALUES}->[0] if !wantarray;
86 19         24 return @{$self->{VALUES}};
  19         81  
87             }
88              
89              
90             sub setAttribs
91             {
92 775     775 0 914 my $self = shift;
93 775         1355 my (%attribs) = @_;
94 775         1773 $self->{ATTRIBS} = \%attribs;
95             }
96              
97              
98             sub getAttribs
99             {
100 47     47 0 82 my $self = shift;
101 47 100       63 return unless (scalar(keys(%{$self->{ATTRIBS}})) > 0);
  47         304  
102 2         5 return %{$self->{ATTRIBS}};
  2         11  
103             }
104              
105              
106             sub setValid
107             {
108 700     700 0 936 my $self = shift;
109 700         770 my $valid = shift;
110 700         1405 $self->{VALID} = $valid;
111             }
112              
113              
114             sub check
115             {
116 123     123 0 192 my $self = shift;
117 123         464 return $self->{VALID};
118             }
119              
120              
121             sub in_context
122             {
123 1138     1138 0 1376 my $self = shift;
124 1138         1229 my $in_context = shift;
125              
126 1138 100       2192 if (defined($in_context))
127             {
128 1031         1518 $self->{INCONTEXT} = $in_context;
129             }
130 1138         2131 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