line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hide from PAUSE |
2
|
|
|
|
|
|
|
Visitor; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=encoding utf8 |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Visitor - a sample Visitor object for Netscape bookmarks |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Netscape::Bookmarks; |
13
|
|
|
|
|
|
|
use Visitor; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $netscape = Netscape::Bookmarks->new( 'Bookmarks.html' ); |
16
|
|
|
|
|
|
|
my $visitor = Visitor->new(); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $netscape->introduce( $visitor ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This class is an example Visitor class for Netscape::Bookmarks. |
23
|
|
|
|
|
|
|
It dispatches the visit to a method depending on what sort |
24
|
|
|
|
|
|
|
of object it visits. For all objects, a short message is |
25
|
|
|
|
|
|
|
output to standard output. For a link object, it calls in |
26
|
|
|
|
|
|
|
HTTP::SimpleLinkChecker if you have it and then checks the |
27
|
|
|
|
|
|
|
link. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
You can use this as a starting point for your own Visitor. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 METHODS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over 4 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item new() |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
No big whoop. It simply creates an uninteresting object that |
38
|
|
|
|
|
|
|
knows it's class so we can dispatch with it. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new |
43
|
|
|
|
|
|
|
{ |
44
|
1
|
|
|
1
|
|
9
|
my( $class ) = shift; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
2
|
my $name = __PACKAGE__; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
3
|
bless \$name, $class; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item visit() |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
The Netscape::AcceptVisitors module requires this method. Use |
54
|
|
|
|
|
|
|
visit() to dispatch a visit to the right method. How you do that |
55
|
|
|
|
|
|
|
is up to you. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Beyond that, look at the code. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub visit { |
62
|
17
|
|
|
17
|
|
40
|
my( $self, $object ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
17
|
|
|
|
|
51
|
my $class = ref $object; |
65
|
17
|
|
|
|
|
121
|
$class =~ s/.*:://; |
66
|
|
|
|
|
|
|
|
67
|
17
|
|
|
|
|
67
|
$self->$class($object); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub Category { |
71
|
5
|
|
|
5
|
|
16
|
my( $self, $object ) = @_; |
72
|
|
|
|
|
|
|
|
73
|
5
|
|
|
|
|
160
|
print STDERR "\tFound category!\n"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub Alias { |
77
|
1
|
|
|
1
|
|
3
|
my( $self, $object ) = @_; |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
74
|
print STDERR "\tFound Alias!\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub Separator { |
83
|
2
|
|
|
2
|
|
8
|
my( $self, $object ) = @_; |
84
|
|
|
|
|
|
|
|
85
|
2
|
|
|
|
|
91
|
print STDERR "\tFound Separator!\n"; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub Link { |
89
|
9
|
|
|
9
|
|
22
|
my( $self, $object ) = @_; |
90
|
9
|
|
|
|
|
242
|
print STDERR "\tFound Link!\n"; |
91
|
9
|
50
|
|
|
|
603
|
return unless require HTTP::SimpleLinkChecker; |
92
|
|
|
|
|
|
|
|
93
|
9
|
|
|
|
|
403330
|
my $code = HTTP::SimpleLinkChecker::check_link( $object->href ); |
94
|
|
|
|
|
|
|
|
95
|
9
|
|
|
|
|
7168071
|
print STDERR "\t\tLink has status $code\n"; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |