line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RDF::Query::VariableBindings |
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Query::VariableBindings - Variable bindings |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Query::VariableBindings version 2.916. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 METHODS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Beyond the methods documented below, this class inherits methods from the |
15
|
|
|
|
|
|
|
L<RDF::Trine::VariableBindings> class. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=over 4 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package RDF::Query::VariableBindings; |
22
|
|
|
|
|
|
|
|
23
|
35
|
|
|
35
|
|
178
|
use strict; |
|
35
|
|
|
|
|
78
|
|
|
35
|
|
|
|
|
854
|
|
24
|
35
|
|
|
35
|
|
176
|
use warnings; |
|
35
|
|
|
|
|
75
|
|
|
35
|
|
|
|
|
905
|
|
25
|
35
|
|
|
35
|
|
171
|
use base qw(RDF::Trine::VariableBindings); |
|
35
|
|
|
|
|
69
|
|
|
35
|
|
|
|
|
4179
|
|
26
|
539
|
|
|
539
|
|
4180
|
use overload '""' => sub { $_[0]->as_string }, |
27
|
35
|
|
|
35
|
|
207
|
'bool' => sub { return 1 }; |
|
35
|
|
|
781
|
|
84
|
|
|
35
|
|
|
|
|
524
|
|
|
781
|
|
|
|
|
4562
|
|
28
|
|
|
|
|
|
|
|
29
|
35
|
|
|
35
|
|
2976
|
use Scalar::Util qw(blessed refaddr); |
|
35
|
|
|
|
|
96
|
|
|
35
|
|
|
|
|
2655
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
###################################################################### |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our ($VERSION); |
34
|
|
|
|
|
|
|
BEGIN { |
35
|
35
|
|
|
35
|
|
15123
|
$VERSION = '2.916'; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
###################################################################### |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item C<< new ( \%bindings ) >> |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
45
|
801
|
|
|
801
|
1
|
8188
|
my $class = shift; |
46
|
801
|
|
50
|
|
|
2170
|
my $bindings = shift || {}; |
47
|
801
|
|
|
|
|
34387
|
my $data = { %$bindings }; |
48
|
801
|
|
|
|
|
2416
|
foreach my $k (keys %$data) { |
49
|
1599
|
|
|
|
|
11372
|
my $node = $data->{$k}; |
50
|
1599
|
100
|
100
|
|
|
11287
|
if (ref($node) and not($node->isa('RDF::Query::Node'))) { |
51
|
761
|
|
|
|
|
2479
|
$data->{$k} = RDF::Query::Node->from_trine( $node ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
801
|
|
|
|
|
10445
|
my $self = $class->SUPER::new( $data ); |
56
|
801
|
|
|
|
|
8765
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item C<< sse ( \%context, $indent ) >> |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub sse { |
64
|
7
|
|
|
7
|
1
|
15
|
my $self = shift; |
65
|
7
|
|
|
|
|
13
|
my $context = shift; |
66
|
7
|
|
|
|
|
13
|
my $indent = shift; |
67
|
7
|
|
|
|
|
13
|
my $more = ' '; |
68
|
7
|
|
|
|
|
26
|
my @keys = sort keys %$self; |
69
|
7
|
50
|
|
|
|
45
|
return sprintf('(row %s)', CORE::join(' ', map { '[' . CORE::join(' ', '?' . $_, ($self->{$_}) ? $self->{$_}->as_string : ()) . ']' } (@keys))); |
|
5
|
|
|
|
|
154
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item C<< explain >> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns a string serialization of the variable bindings appropriate for display |
75
|
|
|
|
|
|
|
on the command line. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub explain { |
80
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
81
|
0
|
|
|
|
|
|
my $s = shift; |
82
|
0
|
|
|
|
|
|
my $count = shift; |
83
|
0
|
|
|
|
|
|
my $indent = $s x $count; |
84
|
0
|
|
|
|
|
|
my $string = "${indent}Variable Bindings\n"; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my @keys = sort keys %$self; |
87
|
0
|
|
|
|
|
|
foreach my $k (@keys) { |
88
|
0
|
|
|
|
|
|
$string .= "${indent}${s}$k: " . $self->{$k}->as_string . "\n"; |
89
|
|
|
|
|
|
|
} |
90
|
0
|
|
|
|
|
|
return $string; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item C<< as_hash >> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Returns the variable bindings as a nested set of plain data structures (no objects). |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub as_hash { |
100
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
101
|
0
|
|
|
|
|
|
my $context = shift; |
102
|
0
|
|
|
|
|
|
my @keys = sort keys %$self; |
103
|
0
|
|
|
|
|
|
return { type => 'bindings', bindings => { map { $_ => $self->{$_}->as_hash($context) } @keys } }; |
|
0
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Gregory Todd Williams <gwilliams@cpan.org> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |