line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Atom::Collection; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
49513
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
406
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
9615
|
use XML::Atom; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use XML::Atom::Service; |
9
|
|
|
|
|
|
|
use base qw(XML::Atom::Base); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_attr_accessors(qw(href)); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub element_name { 'collection' } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub element_ns { $XML::Atom::Service::DefaultNamespace } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub title { |
18
|
|
|
|
|
|
|
my($self, $title) = @_; |
19
|
|
|
|
|
|
|
my $ns_uri = $XML::Atom::Util::NS_MAP{$XML::Atom::DefaultVersion}; |
20
|
|
|
|
|
|
|
my $atom = XML::Atom::Namespace->new(atom => $ns_uri); |
21
|
|
|
|
|
|
|
if (defined $title) { |
22
|
|
|
|
|
|
|
$self->set($atom, 'title', $title); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
|
|
|
|
|
|
$self->get($atom, 'title'); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__PACKAGE__->mk_object_list_accessor('categories' => 'XML::Atom::Categories'); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# accessors to text elements, multiple which there can be |
32
|
|
|
|
|
|
|
unless (XML::Atom::Base->can('mk_elem_list_accessor')) { |
33
|
|
|
|
|
|
|
use XML::Atom::Util qw(childlist create_element); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
*XML::Atom::Base::mk_elem_list_accessor = sub { |
36
|
|
|
|
|
|
|
my($class, $name, $moniker) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
no strict 'refs'; ## no critic |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
*{"$class\::$name"} = sub { |
41
|
|
|
|
|
|
|
my($obj, @args) = @_; |
42
|
|
|
|
|
|
|
my $ns_uri = $class->element_ns || $obj->ns; |
43
|
|
|
|
|
|
|
if (@args) { |
44
|
|
|
|
|
|
|
# setter: clear existent elements first |
45
|
|
|
|
|
|
|
my @elem = childlist($obj->elem, $ns_uri, $name); |
46
|
|
|
|
|
|
|
for my $el (@elem) { |
47
|
|
|
|
|
|
|
$obj->elem->removeChild($el); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# add the new elements for each |
51
|
|
|
|
|
|
|
my $adder = "add_$name"; |
52
|
|
|
|
|
|
|
for my $add_elem (@args) { |
53
|
|
|
|
|
|
|
$obj->$adder($add_elem); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
|
|
|
|
|
|
# getter: |
58
|
|
|
|
|
|
|
my @children = map { $_->textContent } childlist( $obj->elem, $ns_uri, $name ); |
59
|
|
|
|
|
|
|
wantarray ? @children : $children[0]; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
if ($moniker) { |
64
|
|
|
|
|
|
|
*{"$class\::$moniker"} = sub { |
65
|
|
|
|
|
|
|
my($obj, @args) = @_; |
66
|
|
|
|
|
|
|
if (@args) { |
67
|
|
|
|
|
|
|
return $obj->$name(@args); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else { |
70
|
|
|
|
|
|
|
my @obj = $obj->$name; |
71
|
|
|
|
|
|
|
return wantarray ? @obj : \@obj; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
*{"$class\::add_$name"} = sub { |
77
|
|
|
|
|
|
|
my($obj, $stuff) = @_; |
78
|
|
|
|
|
|
|
my $ns_uri = $class->element_ns || $obj->ns; |
79
|
|
|
|
|
|
|
my $elem = create_element($ns_uri, 'accept'); |
80
|
|
|
|
|
|
|
$elem->appendText($stuff); |
81
|
|
|
|
|
|
|
$obj->elem->appendChild($elem); |
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__PACKAGE__->mk_elem_list_accessor('accept', 'accepts'); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
__END__ |