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