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.915_01. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package RDF::Query::Node::Resource; |
15
|
|
|
|
|
|
|
|
16
|
36
|
|
|
36
|
|
186
|
use strict; |
|
36
|
|
|
|
|
69
|
|
|
36
|
|
|
|
|
904
|
|
17
|
36
|
|
|
36
|
|
180
|
use warnings; |
|
36
|
|
|
|
|
67
|
|
|
36
|
|
|
|
|
971
|
|
18
|
36
|
|
|
36
|
|
176
|
no warnings 'redefine'; |
|
36
|
|
|
|
|
63
|
|
|
36
|
|
|
|
|
1273
|
|
19
|
36
|
|
|
36
|
|
188
|
use base qw(RDF::Query::Node RDF::Trine::Node::Resource); |
|
36
|
|
|
|
|
106
|
|
|
36
|
|
|
|
|
4052
|
|
20
|
|
|
|
|
|
|
|
21
|
36
|
|
|
36
|
|
211
|
use URI; |
|
36
|
|
|
|
|
90
|
|
|
36
|
|
|
|
|
1002
|
|
22
|
36
|
|
|
36
|
|
192
|
use Encode; |
|
36
|
|
|
|
|
67
|
|
|
36
|
|
|
|
|
3440
|
|
23
|
36
|
|
|
36
|
|
177
|
use Data::Dumper; |
|
36
|
|
|
|
|
88
|
|
|
36
|
|
|
|
|
1603
|
|
24
|
36
|
|
|
36
|
|
29778
|
use RDF::Query::Parser::SPARQL; |
|
36
|
|
|
|
|
112
|
|
|
36
|
|
|
|
|
1614
|
|
25
|
36
|
|
|
36
|
|
320
|
use Scalar::Util qw(blessed reftype); |
|
36
|
|
|
|
|
75
|
|
|
36
|
|
|
|
|
2501
|
|
26
|
36
|
|
|
36
|
|
198
|
use Carp qw(carp croak confess); |
|
36
|
|
|
|
|
79
|
|
|
36
|
|
|
|
|
2572
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
###################################################################### |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our ($VERSION); |
31
|
|
|
|
|
|
|
BEGIN { |
32
|
36
|
|
|
36
|
|
6348
|
$VERSION = '2.915_01'; |
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
|
|
1078
|
'<' => sub { _cmp(@_) == -1 }, |
50
|
1
|
|
|
1
|
|
352
|
'>' => sub { _cmp(@_) == 1 }, |
51
|
1
|
|
|
1
|
|
379
|
'!=' => sub { _cmp(@_) != 0 }, |
52
|
18
|
|
|
18
|
|
690
|
'==' => sub { _cmp(@_) == 0 }, |
53
|
0
|
|
|
0
|
|
0
|
'+' => sub { $_[0] }, |
54
|
1668
|
|
|
1668
|
|
946788
|
'""' => sub { $_[0]->sse }, |
55
|
36
|
|
|
36
|
|
209
|
; |
|
36
|
|
|
|
|
78
|
|
|
36
|
|
|
|
|
695
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _cmp { |
58
|
25
|
|
|
25
|
|
230
|
my $a = shift; |
59
|
25
|
|
|
|
|
38
|
my $b = shift; |
60
|
25
|
50
|
|
|
|
106
|
return 1 unless blessed($b); |
61
|
25
|
100
|
|
|
|
168
|
return -1 if ($b->isa('RDF::Query::Node::Literal')); |
62
|
22
|
50
|
|
|
|
104
|
return -1 if ($b->isa('RDF::Trine::Node::Nil')); |
63
|
22
|
50
|
|
|
|
104
|
return 1 if ($b->isa('RDF::Query::Node::Blank')); |
64
|
22
|
50
|
|
|
|
81
|
return 0 unless ($b->isa('RDF::Query::Node::Resource')); |
65
|
22
|
|
|
|
|
76
|
my $cmp = $a->uri_value cmp $b->uri_value; |
66
|
22
|
|
|
|
|
238
|
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
|
798
|
my $self = shift; |
77
|
283
|
|
100
|
|
|
774
|
my $context = shift || {}; |
78
|
283
|
50
|
|
|
|
668
|
if ($context) { |
79
|
283
|
|
|
|
|
744
|
my $uri = $self->uri_value; |
80
|
283
|
|
100
|
|
|
1906
|
my $ns = $context->{namespaces} || {}; |
81
|
283
|
|
|
|
|
733
|
my %ns = %$ns; |
82
|
283
|
|
|
|
|
847
|
foreach my $k (keys %ns) { |
83
|
36
|
|
|
36
|
|
11165
|
no warnings 'uninitialized'; |
|
36
|
|
|
|
|
91
|
|
|
36
|
|
|
|
|
8577
|
|
84
|
52
|
50
|
|
|
|
111
|
if ($k eq '__DEFAULT__') { |
85
|
0
|
|
|
|
|
0
|
$k = ''; |
86
|
|
|
|
|
|
|
} |
87
|
52
|
|
|
|
|
74
|
my $v = $ns{ $k }; |
88
|
52
|
100
|
|
|
|
188
|
if (index($uri, $v) == 0) { |
89
|
41
|
|
|
|
|
116
|
my $local = substr($uri, length($v)); |
90
|
41
|
50
|
|
|
|
590
|
if ($local =~ $RDF::Query::Parser::SPARQL::r_PN_LOCAL) { |
91
|
41
|
|
|
|
|
94
|
my $qname = join(':', $k, $local); |
92
|
41
|
|
|
|
|
182
|
return $qname; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
242
|
|
|
|
|
737
|
my $string = URI->new( encode_utf8($self->uri_value) )->canonical; |
99
|
242
|
|
|
|
|
36946
|
my $sparql = '<' . $string . '>'; |
100
|
242
|
|
|
|
|
1781
|
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 |