| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
3
|
|
|
3
|
|
10345
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
170
|
|
|
2
|
|
|
|
|
|
|
package XML::XBEL::Bookmark; |
|
3
|
|
|
|
|
|
|
|
|
4
|
3
|
|
|
|
|
1259
|
use base qw (XML::XBEL::thingy |
|
5
|
|
|
|
|
|
|
XML::XBEL::item |
|
6
|
|
|
|
|
|
|
XML::XBEL::url |
|
7
|
|
|
|
|
|
|
XML::XBEL::node |
|
8
|
3
|
|
|
3
|
|
18
|
XML::XBEL::serialize); |
|
|
3
|
|
|
|
|
6
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# $Id: Bookmark.pm,v 1.4 2004/06/23 06:23:57 asc Exp $ |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
XML::XBEL::Bookmark - OOP for reading and writing XBEL bookmarks. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use XML::XBEL::Bookmark; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
OOP for reading and writing XBEL bookmarks. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use XML::LibXML; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 PACKAGE METHODS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 __PACKAGE__->new(\%args) |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Valid args are: |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=over 4 |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item * B |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
String. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item * B |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
String. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * B |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
String. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * B |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
String. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * B |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
String. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * B |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
String. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item * B |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
String. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * B |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Hash ref, with the following key/value pairs : |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over 6 |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * I |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Array ref. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=back |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns a I object. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub new { |
|
85
|
|
|
|
|
|
|
my $pkg = shift; |
|
86
|
|
|
|
|
|
|
my $args = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $root = XML::LibXML::Element->new("bookmark"); |
|
89
|
|
|
|
|
|
|
my $self = bless {'__root' => $root }, $pkg; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
foreach my $el ("title","href","id","desc","added","info","modified","visited") { |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
if (! exists($args->{$el})) { |
|
94
|
|
|
|
|
|
|
next; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$self->$el($args->{$el}); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
if (! $self->added()) { |
|
101
|
|
|
|
|
|
|
$self->added($self->_now()); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
return $self; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 $obj->href(href) |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Get/set the href attribute for an XBEL bookmark. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
If modified, the object's I method is |
|
116
|
|
|
|
|
|
|
automatically called with the current datetime. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub href { |
|
121
|
|
|
|
|
|
|
my $self = shift; |
|
122
|
|
|
|
|
|
|
my $href = shift; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
if (defined($href)) { |
|
125
|
|
|
|
|
|
|
$self->modified($self->_now()); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
return $self->SUPER::href($href); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 $obj->title($title) |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Get/set the title for an XBEL bookmark. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
If modified, the object's I method is |
|
136
|
|
|
|
|
|
|
automatically called with the current datetime. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns a string when called with no arguments; |
|
139
|
|
|
|
|
|
|
otherwise returns true or false. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub title { |
|
144
|
|
|
|
|
|
|
my $self = shift; |
|
145
|
|
|
|
|
|
|
my $title = shift; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
if (defined($title)) { |
|
148
|
|
|
|
|
|
|
$self->modified($self->_now()); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
return $self->SUPER::title($title); |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 $obj->desc($description) |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Get/set the description for an XBEL bookmark. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
If modified, the object's I method is |
|
159
|
|
|
|
|
|
|
automatically called with the current datetime. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Returns a string when called with no arguments; |
|
162
|
|
|
|
|
|
|
otherwise returns true or false. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# Defined in XML::XBEL::item |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 $obj->info(\%args) |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Get/set the metadata for an XBEL document. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Valid args are : |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=over 4 |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item * B |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Array reference |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=back |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Returns an array reference when called with no arguments; |
|
183
|
|
|
|
|
|
|
otherwise returns true or false. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 $obj->id($id) |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Get/set the id attribute for an XBEL bookmark. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
If modified, the object's I method is |
|
192
|
|
|
|
|
|
|
automatically called with the current datetime. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Returns a string when called with no arguments; |
|
195
|
|
|
|
|
|
|
otherwise returns true or false. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=cut |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub id { |
|
200
|
|
|
|
|
|
|
my $self = shift; |
|
201
|
|
|
|
|
|
|
my $id = shift; |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
if (defined($id)) { |
|
204
|
|
|
|
|
|
|
$self->modified($self->_now()); |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
return $self->SUPER::id($id); |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 $obj->added($datetime) |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Get/set the creation datetime for an XBEL bookmark. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Returns a string when called with no arguments; |
|
215
|
|
|
|
|
|
|
otherwise returns true or false. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
# Defined in XML::XBEL::node |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head2 $obj->modified($datetime) |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Get/set the last modified datetime for an XBEL bookmark. |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Returns a string when called with no arguments; |
|
226
|
|
|
|
|
|
|
otherwise returns true or false. |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=cut |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
# Defined in XML::XBEL::url |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 $obj->visited($datetime) |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Get/set the last visited datetime for an XBEL bookmark. |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Returns a string when called with no arguments; |
|
237
|
|
|
|
|
|
|
otherwise returns true or false. |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=cut |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# Defined in XML::XBEL::url |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 $obj->toString($format) |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=cut |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
# Defined in XML::XBEL::serialize |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 $obj->toFile($filename,$format) |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=cut |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
# Defined in XML::XBEL::serialize |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head2 $obj->toFH(\*$fh,$format) |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=cut |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# Defined in XML::XBEL::serialize |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 VERSION |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
$Revision: 1.4 $ |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 DATE |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
$Date: 2004/06/23 06:23:57 $ |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 AUTHOR |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Aaron Straup Cope Eascope@cpan.orgE |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
L |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
L |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
L |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
L |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=head1 LICENSE |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Copyright (c) 2004 Aaron Straup Cope. All rights reserved. |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
This is free software, you may use it and distribute it under the |
|
288
|
|
|
|
|
|
|
same terms as Perl itself. |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=cut |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
return 1; |