line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Netscape::Bookmarks::Alias; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Netscape::Bookmarks::Alias - object for an Alias in a Netscape Bookmarks file |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Netscape::Bookmarks; |
12
|
|
|
|
|
|
|
use Netscape::Bookmarks::Alias; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $bookmarks = Netscape::Bookmarks->new(); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $alias = Netscape::Bookmarks::Alias->new(); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$bookmarks->add( $alias ); |
19
|
|
|
|
|
|
|
# ... and other Netscape::Bookmark::Category methods |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This module provides an abstraction for an Alias object in a Netscape |
24
|
|
|
|
|
|
|
Bookmarks file. An alias is simply a reference to another link in the |
25
|
|
|
|
|
|
|
Bookmarks file, henceforth called the target. If you change the alias, |
26
|
|
|
|
|
|
|
the target link also changes. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over 4 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
6
|
|
|
6
|
|
20858
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
188
|
|
33
|
|
|
|
|
|
|
|
34
|
6
|
|
|
6
|
|
28
|
use base qw( Netscape::Bookmarks::AcceptVisitor Netscape::Bookmarks::Isa ); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
3402
|
|
35
|
6
|
|
|
6
|
|
34
|
use subs qw(); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
137
|
|
36
|
6
|
|
|
6
|
|
30
|
use vars qw($VERSION $ERROR %aliases); |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
2641
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$VERSION = "2.301"; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item $obj = Netscape::Bookmarks::Alias->new( ALIASID ) |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Creates a new C object with the ALIASOF |
43
|
|
|
|
|
|
|
attribute value of ALIASID. This object relies on a corresponding |
44
|
|
|
|
|
|
|
C object with the same ALIASID, although |
45
|
|
|
|
|
|
|
C does not check to see if that object exists (although it probably |
46
|
|
|
|
|
|
|
should). |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub new { |
51
|
2
|
|
|
2
|
1
|
6
|
my $class = shift; |
52
|
2
|
|
|
|
|
5
|
my $param = shift; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
5
|
my $self = {}; |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
4
|
bless $self, $class; |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
15
|
$self->{'alias_of'} = $param; |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
6
|
$self; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item $obj->alias_of() |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns the alias key for this C object. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub alias_of { |
70
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
return $self->{'alias_of'}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item $obj->target( ALIAS_KEY ) |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Returns the target Link of the given alias key. The return value |
78
|
|
|
|
|
|
|
is a C object if the target exists, or |
79
|
|
|
|
|
|
|
C in scalar context or the empty list in list context if the |
80
|
|
|
|
|
|
|
target does not exist. If you want to simply check to see if a |
81
|
|
|
|
|
|
|
target exists, use C. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub target { |
86
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
5
|
return $aliases{$self->{'alias_of'}}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item add_target( $link_obj, ALIAS_KEY ) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Adds a target link for the given ALIAS_KEY. You can add target |
94
|
|
|
|
|
|
|
links before the Alias is created. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# this should really be in Link.pm right? |
99
|
|
|
|
|
|
|
sub add_target { |
100
|
2
|
|
|
2
|
1
|
5
|
my $target = shift; #link reference |
101
|
2
|
|
|
|
|
5
|
my $alias_id = shift; |
102
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
9
|
$target->aliasid($alias_id); |
104
|
2
|
|
|
|
|
8
|
$aliases{$alias_id} = $target; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item target_exists( TARGET_KEY ) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
For the given target key returns TRUE or FALSE if the target |
110
|
|
|
|
|
|
|
exists. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub target_exists { |
115
|
0
|
|
|
0
|
1
|
0
|
my $target = shift; |
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
0
|
exists $aliases{$target} ? 1 : 0; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item $obj->as_string() |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns a string representation on the alias. This is |
123
|
|
|
|
|
|
|
almost identical from the representation of the link which |
124
|
|
|
|
|
|
|
is aliases except that the ALIASID attribute is changed |
125
|
|
|
|
|
|
|
to the ALIASOF attribute. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub as_string { |
130
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
|
|
4
|
my $string = $self->target->as_string; |
133
|
|
|
|
|
|
|
|
134
|
1
|
|
|
|
|
5
|
$string =~ s/ALIASID/ALIASOF/; |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
4
|
return $string; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item $obj->title() |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns the tile of the Alias. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub title { |
146
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
return "Alias: " . $self->target->title; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item $obj->remove() |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Performs any clean up necessary to remove this object from the |
154
|
|
|
|
|
|
|
Bookmarks tree. Although this method does not affect the Link object |
155
|
|
|
|
|
|
|
which is its target, it probably should. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub remove { |
160
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
return 1; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
"if you want to believe everything you read, so be it."; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=back |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 AUTHOR |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
brian d foy C<< >> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Copyright © 2002-2016, brian d foy . All rights reserved. |
176
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
177
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 SEE ALSO |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L, L |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
__END__ |