line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package XML::Atom::Entry; |
4
|
19
|
|
|
19
|
|
459906
|
use strict; |
|
19
|
|
|
|
|
71
|
|
|
19
|
|
|
|
|
798
|
|
5
|
|
|
|
|
|
|
|
6
|
19
|
|
|
19
|
|
1433
|
use XML::Atom; |
|
19
|
|
|
|
|
49
|
|
|
19
|
|
|
|
|
1077
|
|
7
|
19
|
|
|
19
|
|
122
|
use base qw( XML::Atom::Thing ); |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
4554
|
|
8
|
19
|
|
|
19
|
|
10179
|
use MIME::Base64 qw( encode_base64 decode_base64 ); |
|
19
|
|
|
|
|
13930
|
|
|
19
|
|
|
|
|
1285
|
|
9
|
19
|
|
|
19
|
|
7935
|
use XML::Atom::Person; |
|
19
|
|
|
|
|
46
|
|
|
19
|
|
|
|
|
3602
|
|
10
|
19
|
|
|
19
|
|
10095
|
use XML::Atom::Content; |
|
19
|
|
|
|
|
59
|
|
|
19
|
|
|
|
|
774
|
|
11
|
19
|
|
|
19
|
|
164
|
use XML::Atom::Util qw( first ); |
|
19
|
|
|
|
|
35
|
|
|
19
|
|
|
|
|
4036
|
|
12
|
|
|
|
|
|
|
|
13
|
12
|
|
|
12
|
0
|
232
|
sub element_name { 'entry' } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub content { |
16
|
32
|
|
|
32
|
1
|
2838
|
my $entry = shift; |
17
|
32
|
100
|
|
|
|
133
|
if (my @arg = @_) { |
18
|
9
|
50
|
|
|
|
37
|
if (ref($arg[0]) ne 'XML::Atom::Content') { |
19
|
9
|
|
|
|
|
48
|
$arg[0] = XML::Atom::Content->new(Body => $arg[0], Version => $entry->version); |
20
|
|
|
|
|
|
|
} |
21
|
9
|
|
|
|
|
33
|
$entry->set($entry->ns, 'content', @arg); |
22
|
|
|
|
|
|
|
} else { |
23
|
23
|
|
|
|
|
78
|
return $entry->get_object($entry->ns, 'content', 'XML::Atom::Content'); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__PACKAGE__->mk_elem_accessors(qw( summary )); |
28
|
|
|
|
|
|
|
__PACKAGE__->mk_xml_attr_accessors(qw( lang base )); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__PACKAGE__->_rename_elements('issued' => 'published'); |
31
|
|
|
|
|
|
|
__PACKAGE__->_rename_elements('modified' => 'updated'); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# OMG 0.3 elements ... to be backward compatible |
34
|
|
|
|
|
|
|
__PACKAGE__->mk_elem_accessors(qw( created )); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__PACKAGE__->mk_object_accessor( source => 'XML::Atom::Feed' ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
XML::Atom::Entry - Atom entry |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use XML::Atom::Entry; |
48
|
|
|
|
|
|
|
my $entry = XML::Atom::Entry->new; |
49
|
|
|
|
|
|
|
$entry->title('My Post'); |
50
|
|
|
|
|
|
|
$entry->content('The content of my post.'); |
51
|
|
|
|
|
|
|
my $xml = $entry->as_xml; |
52
|
|
|
|
|
|
|
my $dc = XML::Atom::Namespace->new(dc => 'http://purl.org/dc/elements/1.1/'); |
53
|
|
|
|
|
|
|
$entry->set($dc, 'subject', 'Food & Drink'); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 USAGE |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 XML::Atom::Entry->new([ $stream ]) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Creates a new entry object, and if I<$stream> is supplied, fills it with the |
60
|
|
|
|
|
|
|
data specified by I<$stream>. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Automatically handles autodiscovery if I<$stream> is a URI (see below). |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns the new I<XML::Atom::Entry> object. On failure, returns C<undef>. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
I<$stream> can be any one of the following: |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over 4 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * Reference to a scalar |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This is treated as the XML body of the entry. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * Scalar |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is treated as the name of a file containing the entry XML. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * Filehandle |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This is treated as an open filehandle from which the entry XML can be read. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 $entry->content([ $content ]) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns the content of the entry. If I<$content> is given, sets the content |
87
|
|
|
|
|
|
|
of the entry. Automatically handles all necessary escaping. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 $entry->author([ $author ]) |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns an I<XML::Atom::Person> object representing the author of the entry, |
92
|
|
|
|
|
|
|
or C<undef> if there is no author information present. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
If I<$author> is supplied, it should be an I<XML::Atom::Person> object |
95
|
|
|
|
|
|
|
representing the author. For example: |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $author = XML::Atom::Person->new; |
98
|
|
|
|
|
|
|
$author->name('Foo Bar'); |
99
|
|
|
|
|
|
|
$author->email('foo@bar.com'); |
100
|
|
|
|
|
|
|
$entry->author($author); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 $entry->link |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
If called in scalar context, returns an I<XML::Atom::Link> object |
105
|
|
|
|
|
|
|
corresponding to the first I<E<lt>linkE<gt>> tag found in the entry. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
If called in list context, returns a list of I<XML::Atom::Link> objects |
108
|
|
|
|
|
|
|
corresponding to all of the I<E<lt>linkE<gt>> tags found in the entry. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 $entry->add_link($link) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Adds the link I<$link>, which must be an I<XML::Atom::Link> object, to |
113
|
|
|
|
|
|
|
the entry as a new I<E<lt>linkE<gt>> tag. For example: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $link = XML::Atom::Link->new; |
116
|
|
|
|
|
|
|
$link->type('text/html'); |
117
|
|
|
|
|
|
|
$link->rel('alternate'); |
118
|
|
|
|
|
|
|
$link->href('http://www.example.com/2003/12/post.html'); |
119
|
|
|
|
|
|
|
$entry->add_link($link); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 $entry->get($ns, $element) |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Given an I<XML::Atom::Namespace> element I<$ns> and an element name |
124
|
|
|
|
|
|
|
I<$element>, retrieves the value for the element in that namespace. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is useful for retrieving the value of elements not in the main Atom |
127
|
|
|
|
|
|
|
namespace, like categories. For example: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $dc = XML::Atom::Namespace->new(dc => 'http://purl.org/dc/elements/1.1/'); |
130
|
|
|
|
|
|
|
my $subj = $entry->get($dc, 'subject'); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 $entry->getlist($ns, $element) |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Just like I<$entry-E<gt>get>, but if there are multiple instances of the |
135
|
|
|
|
|
|
|
element I<$element> in the namespace I<$ns>, returns all of them. I<get> |
136
|
|
|
|
|
|
|
will return only the first. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 AUTHOR & COPYRIGHT |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Please see the I<XML::Atom> manpage for author, copyright, and license |
141
|
|
|
|
|
|
|
information. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |