| 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.918. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package RDF::Query::Node::Resource; |
|
15
|
|
|
|
|
|
|
|
|
16
|
36
|
|
|
36
|
|
138
|
use strict; |
|
|
36
|
|
|
|
|
46
|
|
|
|
36
|
|
|
|
|
853
|
|
|
17
|
36
|
|
|
36
|
|
135
|
use warnings; |
|
|
36
|
|
|
|
|
47
|
|
|
|
36
|
|
|
|
|
777
|
|
|
18
|
36
|
|
|
36
|
|
115
|
no warnings 'redefine'; |
|
|
36
|
|
|
|
|
49
|
|
|
|
36
|
|
|
|
|
923
|
|
|
19
|
36
|
|
|
36
|
|
123
|
use base qw(RDF::Query::Node RDF::Trine::Node::Resource); |
|
|
36
|
|
|
|
|
48
|
|
|
|
36
|
|
|
|
|
2956
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
36
|
|
|
36
|
|
194
|
use URI; |
|
|
36
|
|
|
|
|
49
|
|
|
|
36
|
|
|
|
|
707
|
|
|
22
|
36
|
|
|
36
|
|
134
|
use Encode; |
|
|
36
|
|
|
|
|
46
|
|
|
|
36
|
|
|
|
|
2544
|
|
|
23
|
36
|
|
|
36
|
|
140
|
use Data::Dumper; |
|
|
36
|
|
|
|
|
44
|
|
|
|
36
|
|
|
|
|
1226
|
|
|
24
|
36
|
|
|
36
|
|
16930
|
use RDF::Query::Parser::SPARQL; |
|
|
36
|
|
|
|
|
75
|
|
|
|
36
|
|
|
|
|
1527
|
|
|
25
|
36
|
|
|
36
|
|
297
|
use Scalar::Util qw(blessed reftype); |
|
|
36
|
|
|
|
|
54
|
|
|
|
36
|
|
|
|
|
2221
|
|
|
26
|
36
|
|
|
36
|
|
152
|
use Carp qw(carp croak confess); |
|
|
36
|
|
|
|
|
53
|
|
|
|
36
|
|
|
|
|
2042
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
###################################################################### |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our ($VERSION); |
|
31
|
|
|
|
|
|
|
BEGIN { |
|
32
|
36
|
|
|
36
|
|
4687
|
$VERSION = '2.918'; |
|
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
|
|
1217
|
'<' => sub { _cmp(@_) == -1 }, |
|
50
|
1
|
|
|
1
|
|
391
|
'>' => sub { _cmp(@_) == 1 }, |
|
51
|
1
|
|
|
1
|
|
384
|
'!=' => sub { _cmp(@_) != 0 }, |
|
52
|
18
|
|
|
18
|
|
638
|
'==' => sub { _cmp(@_) == 0 }, |
|
53
|
0
|
|
|
0
|
|
0
|
'+' => sub { $_[0] }, |
|
54
|
1667
|
|
|
1667
|
|
709581
|
'""' => sub { $_[0]->sse }, |
|
55
|
36
|
|
|
36
|
|
194
|
; |
|
|
36
|
|
|
|
|
47
|
|
|
|
36
|
|
|
|
|
511
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _cmp { |
|
58
|
25
|
|
|
25
|
|
248
|
my $a = shift; |
|
59
|
25
|
|
|
|
|
24
|
my $b = shift; |
|
60
|
25
|
50
|
|
|
|
81
|
return 1 unless blessed($b); |
|
61
|
25
|
100
|
|
|
|
140
|
return -1 if ($b->isa('RDF::Query::Node::Literal')); |
|
62
|
22
|
50
|
|
|
|
73
|
return -1 if ($b->isa('RDF::Trine::Node::Nil')); |
|
63
|
22
|
50
|
|
|
|
77
|
return 1 if ($b->isa('RDF::Query::Node::Blank')); |
|
64
|
22
|
50
|
|
|
|
55
|
return 0 unless ($b->isa('RDF::Query::Node::Resource')); |
|
65
|
22
|
|
|
|
|
60
|
my $cmp = $a->uri_value cmp $b->uri_value; |
|
66
|
22
|
|
|
|
|
163
|
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
|
586
|
my $self = shift; |
|
77
|
283
|
|
|
|
|
290
|
my $PNLOCAL = $RDF::Query::Parser::SPARQL::r_PN_LOCAL; |
|
78
|
283
|
|
100
|
|
|
570
|
my $context = shift || {}; |
|
79
|
283
|
50
|
|
|
|
500
|
if ($context) { |
|
80
|
283
|
|
|
|
|
554
|
my $uri = $self->uri_value; |
|
81
|
283
|
|
100
|
|
|
1328
|
my $ns = $context->{namespaces} || {}; |
|
82
|
283
|
|
|
|
|
647
|
my %ns = %$ns; |
|
83
|
283
|
|
|
|
|
605
|
foreach my $k (keys %ns) { |
|
84
|
36
|
|
|
36
|
|
8703
|
no warnings 'uninitialized'; |
|
|
36
|
|
|
|
|
58
|
|
|
|
36
|
|
|
|
|
6643
|
|
|
85
|
49
|
50
|
|
|
|
94
|
if ($k eq '__DEFAULT__') { |
|
86
|
0
|
|
|
|
|
0
|
$k = ''; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
49
|
|
|
|
|
60
|
my $v = $ns{ $k }; |
|
89
|
49
|
100
|
|
|
|
165
|
if (index($uri, $v) == 0) { |
|
90
|
41
|
|
|
|
|
114
|
my $local = substr($uri, length($v)); |
|
91
|
|
|
|
|
|
|
|
|
92
|
41
|
50
|
|
|
|
695
|
if ($local =~ /^(?:$PNLOCAL)$/) { |
|
93
|
41
|
|
|
|
|
81
|
my $qname = join(':', $k, $local); |
|
94
|
41
|
|
|
|
|
160
|
return $qname; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
242
|
|
|
|
|
465
|
my $string = URI->new( encode_utf8($self->uri_value) )->canonical; |
|
101
|
242
|
|
|
|
|
26590
|
my $sparql = '<' . $string . '>'; |
|
102
|
242
|
|
|
|
|
1242
|
return $sparql; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item C<< as_hash >> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns the query as a nested set of plain data structures (no objects). |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub as_hash { |
|
112
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
113
|
0
|
|
|
|
|
|
my $context = shift; |
|
114
|
|
|
|
|
|
|
return { |
|
115
|
0
|
|
|
|
|
|
type => 'node', |
|
116
|
|
|
|
|
|
|
iri => $self->uri_value, |
|
117
|
|
|
|
|
|
|
}; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=back |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHOR |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |