line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RDF::Query::Node::Resource |
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::Node::Resource - RDF Node class for resources |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::Node::Resource version 2.916. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package RDF::Query::Node::Resource; |
15
|
|
|
|
|
|
|
|
16
|
36
|
|
|
36
|
|
184
|
use strict; |
|
36
|
|
|
|
|
75
|
|
|
36
|
|
|
|
|
948
|
|
17
|
36
|
|
|
36
|
|
194
|
use warnings; |
|
36
|
|
|
|
|
66
|
|
|
36
|
|
|
|
|
994
|
|
18
|
36
|
|
|
36
|
|
254
|
no warnings 'redefine'; |
|
36
|
|
|
|
|
74
|
|
|
36
|
|
|
|
|
1271
|
|
19
|
36
|
|
|
36
|
|
197
|
use base qw(RDF::Query::Node RDF::Trine::Node::Resource); |
|
36
|
|
|
|
|
71
|
|
|
36
|
|
|
|
|
4265
|
|
20
|
|
|
|
|
|
|
|
21
|
36
|
|
|
36
|
|
213
|
use URI; |
|
36
|
|
|
|
|
74
|
|
|
36
|
|
|
|
|
859
|
|
22
|
36
|
|
|
36
|
|
265
|
use Encode; |
|
36
|
|
|
|
|
73
|
|
|
36
|
|
|
|
|
3605
|
|
23
|
36
|
|
|
36
|
|
194
|
use Data::Dumper; |
|
36
|
|
|
|
|
80
|
|
|
36
|
|
|
|
|
1742
|
|
24
|
36
|
|
|
36
|
|
30825
|
use RDF::Query::Parser::SPARQL; |
|
36
|
|
|
|
|
114
|
|
|
36
|
|
|
|
|
1634
|
|
25
|
36
|
|
|
36
|
|
334
|
use Scalar::Util qw(blessed reftype); |
|
36
|
|
|
|
|
78
|
|
|
36
|
|
|
|
|
2573
|
|
26
|
36
|
|
|
36
|
|
206
|
use Carp qw(carp croak confess); |
|
36
|
|
|
|
|
80
|
|
|
36
|
|
|
|
|
2609
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
###################################################################### |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our ($VERSION); |
31
|
|
|
|
|
|
|
BEGIN { |
32
|
36
|
|
|
36
|
|
6542
|
$VERSION = '2.916'; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
###################################################################### |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Beyond the methods documented below, this class inherits methods from the |
41
|
|
|
|
|
|
|
L<RDF::Query::Node> and L<RDF::Trine::Node::Resource> classes. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over 4 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use overload '<=>' => \&_cmp, |
48
|
|
|
|
|
|
|
'cmp' => \&_cmp, |
49
|
4
|
|
|
4
|
|
1525
|
'<' => sub { _cmp(@_) == -1 }, |
50
|
1
|
|
|
1
|
|
489
|
'>' => sub { _cmp(@_) == 1 }, |
51
|
1
|
|
|
1
|
|
480
|
'!=' => sub { _cmp(@_) != 0 }, |
52
|
20
|
|
|
20
|
|
862
|
'==' => sub { _cmp(@_) == 0 }, |
53
|
0
|
|
|
0
|
|
0
|
'+' => sub { $_[0] }, |
54
|
1672
|
|
|
1672
|
|
960279
|
'""' => sub { $_[0]->sse }, |
55
|
36
|
|
|
36
|
|
231
|
; |
|
36
|
|
|
|
|
77
|
|
|
36
|
|
|
|
|
708
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _cmp { |
58
|
28
|
|
|
28
|
|
266
|
my $a = shift; |
59
|
28
|
|
|
|
|
43
|
my $b = shift; |
60
|
28
|
50
|
|
|
|
124
|
return 1 unless blessed($b); |
61
|
28
|
100
|
|
|
|
210
|
return -1 if ($b->isa('RDF::Query::Node::Literal')); |
62
|
25
|
50
|
|
|
|
124
|
return -1 if ($b->isa('RDF::Trine::Node::Nil')); |
63
|
25
|
100
|
|
|
|
141
|
return 1 if ($b->isa('RDF::Query::Node::Blank')); |
64
|
22
|
50
|
|
|
|
89
|
return 0 unless ($b->isa('RDF::Query::Node::Resource')); |
65
|
22
|
|
|
|
|
81
|
my $cmp = $a->uri_value cmp $b->uri_value; |
66
|
22
|
|
|
|
|
244
|
return $cmp; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item C<< as_sparql >> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns the SPARQL string for this node. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub as_sparql { |
76
|
283
|
|
|
283
|
1
|
835
|
my $self = shift; |
77
|
283
|
|
100
|
|
|
790
|
my $context = shift || {}; |
78
|
283
|
50
|
|
|
|
699
|
if ($context) { |
79
|
283
|
|
|
|
|
802
|
my $uri = $self->uri_value; |
80
|
283
|
|
100
|
|
|
2052
|
my $ns = $context->{namespaces} || {}; |
81
|
283
|
|
|
|
|
751
|
my %ns = %$ns; |
82
|
283
|
|
|
|
|
896
|
foreach my $k (keys %ns) { |
83
|
36
|
|
|
36
|
|
11544
|
no warnings 'uninitialized'; |
|
36
|
|
|
|
|
76
|
|
|
36
|
|
|
|
|
8877
|
|
84
|
50
|
50
|
|
|
|
112
|
if ($k eq '__DEFAULT__') { |
85
|
0
|
|
|
|
|
0
|
$k = ''; |
86
|
|
|
|
|
|
|
} |
87
|
50
|
|
|
|
|
76
|
my $v = $ns{ $k }; |
88
|
50
|
100
|
|
|
|
187
|
if (index($uri, $v) == 0) { |
89
|
41
|
|
|
|
|
118
|
my $local = substr($uri, length($v)); |
90
|
41
|
50
|
|
|
|
577
|
if ($local =~ $RDF::Query::Parser::SPARQL::r_PN_LOCAL) { |
91
|
41
|
|
|
|
|
80
|
my $qname = join(':', $k, $local); |
92
|
41
|
|
|
|
|
186
|
return $qname; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
242
|
|
|
|
|
740
|
my $string = URI->new( encode_utf8($self->uri_value) )->canonical; |
99
|
242
|
|
|
|
|
36903
|
my $sparql = '<' . $string . '>'; |
100
|
242
|
|
|
|
|
1810
|
return $sparql; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item C<< as_hash >> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns the query as a nested set of plain data structures (no objects). |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub as_hash { |
110
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
111
|
0
|
|
|
|
|
|
my $context = shift; |
112
|
|
|
|
|
|
|
return { |
113
|
0
|
|
|
|
|
|
type => 'node', |
114
|
|
|
|
|
|
|
iri => $self->uri_value, |
115
|
|
|
|
|
|
|
}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__END__ |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |