line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
7
|
|
|
7
|
|
2488
|
use strict; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
166
|
|
2
|
7
|
|
|
7
|
|
23
|
use warnings; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
300
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Maven::Xml::XmlNodeParser; |
5
|
|
|
|
|
|
|
$Maven::Xml::XmlNodeParser::VERSION = '1.13'; |
6
|
|
|
|
|
|
|
# ABSTRACT: A parser for a Maven XML node |
7
|
|
|
|
|
|
|
# PODNAME: Maven::Xml::XmlNodeParser |
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
27
|
use parent qw(Class::Accessor); |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
46
|
|
10
|
|
|
|
|
|
|
|
11
|
7
|
|
|
7
|
|
8452
|
use XML::LibXML::Reader qw(:types); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
|
|
|
|
|
|
return bless( {}, shift )->_init(@_); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _add_value { |
18
|
|
|
|
|
|
|
my ( $self, $name, $value ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if ( defined( $self->{$name} ) ) { |
21
|
|
|
|
|
|
|
my $existing = $self->{$name}; |
22
|
|
|
|
|
|
|
if ( ref($existing) eq 'ARRAY' ) { |
23
|
|
|
|
|
|
|
push( @$existing, $value ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
|
|
|
|
|
|
my @values = ( $existing, $value ); |
27
|
|
|
|
|
|
|
$self->{$name} = \@values; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
|
|
|
|
|
|
$self->{$name} = $value; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _init { |
36
|
|
|
|
|
|
|
return $_[0]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _get_parser { |
40
|
|
|
|
|
|
|
return $_[0]; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _key { |
44
|
|
|
|
|
|
|
my ( $self, $default ) = @_; |
45
|
|
|
|
|
|
|
return $default; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _parse_node { |
49
|
|
|
|
|
|
|
my ( $self, $reader, $types ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $name; |
52
|
|
|
|
|
|
|
my $value; |
53
|
|
|
|
|
|
|
while ( $reader->read() ) { |
54
|
|
|
|
|
|
|
if ( $reader->nodeType() == XML_READER_TYPE_ELEMENT ) { |
55
|
|
|
|
|
|
|
$name = $reader->name(); |
56
|
|
|
|
|
|
|
if ( $reader->isEmptyElement() ) { |
57
|
|
|
|
|
|
|
$self->_add_value( $name, undef ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
|
|
|
|
|
|
$self->_add_value( $name, $self->_get_parser($name)->_parse_node($reader) ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
$value = $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
elsif ($reader->nodeType() == XML_READER_TYPE_TEXT |
65
|
|
|
|
|
|
|
|| $reader->nodeType() == XML_READER_TYPE_CDATA ) |
66
|
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
|
$value = $reader->value(); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ( $reader->nodeType() == XML_READER_TYPE_END_ELEMENT ) { |
70
|
|
|
|
|
|
|
return $value; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |