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