line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::FOAF::Person; |
2
|
5
|
|
|
5
|
|
32
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
212
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
8700
|
use RDF::Core::Resource; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
|
|
|
|
|
|
bless { foaf => $_[1], subject => $_[2] }, $_[0]; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub knows { |
11
|
|
|
|
|
|
|
my $person = shift; |
12
|
|
|
|
|
|
|
my $knows = RDF::Core::Resource->new($XML::FOAF::NAMESPACE . 'knows'); |
13
|
|
|
|
|
|
|
my $enum = $person->{foaf}->{model}->getStmts($person->{subject}, $knows); |
14
|
|
|
|
|
|
|
my $stmt = $enum->getFirst; |
15
|
|
|
|
|
|
|
my @knows; |
16
|
|
|
|
|
|
|
while (defined $stmt) { |
17
|
|
|
|
|
|
|
push @knows, XML::FOAF::Person->new($person->{foaf}, $stmt->getObject); |
18
|
|
|
|
|
|
|
$stmt = $enum->getNext; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
\@knows; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get { |
24
|
|
|
|
|
|
|
my $person = shift; |
25
|
|
|
|
|
|
|
my($what) = @_; |
26
|
|
|
|
|
|
|
unless ($what =~ /:/) { |
27
|
|
|
|
|
|
|
$what = $XML::FOAF::NAMESPACE . $what; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
my $res = RDF::Core::Resource->new($what); |
30
|
|
|
|
|
|
|
my $enum = $person->{foaf}->{model}->getStmts($person->{subject}, $res); |
31
|
|
|
|
|
|
|
my $stmt = $enum->getFirst or return undef; |
32
|
|
|
|
|
|
|
$stmt->getObject->getLabel; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub DESTROY { } |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use vars qw( $AUTOLOAD ); |
38
|
|
|
|
|
|
|
sub AUTOLOAD { |
39
|
|
|
|
|
|
|
(my $var = $AUTOLOAD) =~ s!.+::!!; |
40
|
|
|
|
|
|
|
no strict 'refs'; |
41
|
|
|
|
|
|
|
*$AUTOLOAD = sub { $_[0]->get($var) }; |
42
|
|
|
|
|
|
|
goto &$AUTOLOAD; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |