| 1 | # RDF::Query::Node::Variable | ||||||||||||||||||||
| 2 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | RDF::Query::Node::Variable - RDF Node class for variables | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | =head1 VERSION | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | This document describes RDF::Query::Node::Variable version 2.919. | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =cut | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | package RDF::Query::Node::Variable; | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 36 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 36 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 36 | ▶ | no warnings 'redefine'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 36 | ▶ | use base qw(RDF::Query::Node RDF::Trine::Node::Variable); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 36 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 36 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 36 | ▶ | use Carp qw(carp croak confess); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | ###################################################################### | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 36 | our ($VERSION); | |||||||||||||||||||
| 28 | 36 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | 36 | $VERSION = '2.919'; | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | ###################################################################### | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =head1 METHODS | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =head1 METHODS | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | Beyond the methods documented below, this class inherits methods from the | ||||||||||||||||||||
| 39 | L<RDF::Query::Node> and L<RDF::Trine::Node::Variable> classes. | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =over 4 | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =cut | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 36 | ▶ | use overload '""' => sub { $_[0]->sse }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | =item C<< new ( $name ) >> | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | Returns a new variable object. | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 36 | my $COUNTER = 0; | |||||||||||||||||||
| 54 | 1035 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 55 | 1035 | my $class = shift; | |||||||||||||||||||
| 56 | 1035 | my $name = shift; | |||||||||||||||||||
| 57 | 1035 | ▶ | unless (defined($name)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | 45 | $name = 'v' . time() . 'r' . $COUNTER++; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | 1035 | return $class->SUPER::new( $name ); | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =item C<< as_sparql >> | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | Returns the SPARQL string for this node. | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 395 | ▶ | sub as_sparql { | ||||||||||||||||||
|
Subroutine
as_sparql: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 70 | 395 | my $self = shift; | |||||||||||||||||||
| 71 | 395 | return $self->sse; | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | =item C<< as_hash >> | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | Returns the query as a nested set of plain data structures (no objects). | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | =cut | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 0 | ▶ | sub as_hash { | ||||||||||||||||||
|
Subroutine
as_hash: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 81 | 0 | my $self = shift; | |||||||||||||||||||
| 82 | 0 | my $context = shift; | |||||||||||||||||||
| 83 | return { | ||||||||||||||||||||
| 84 | 0 | type => 'node', | |||||||||||||||||||
| 85 | variable => $self->name, | ||||||||||||||||||||
| 86 | }; | ||||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | package RDF::Query::Node::Variable::ExpressionProxy; | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 36 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 92 | 36 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 93 | 36 | ▶ | use base qw(RDF::Query::Node::Variable); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 94 | 36 | ▶ | use Scalar::Util qw(blessed refaddr); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | =begin private | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | =item C<< new >> | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | =cut | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 36 | {my %vars; | |||||||||||||||||||
| 103 | 21 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
| |||||||||||||||||||||
| 104 | 21 | my $class = shift; | |||||||||||||||||||
| 105 | 21 | my $name = shift; | |||||||||||||||||||
| 106 | 21 | my @vars = @_; | |||||||||||||||||||
| 107 | 21 | my $self = $class->SUPER::new( $name ); | |||||||||||||||||||
| 108 | 21 | ▶ | if (@vars) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 109 | 21 | ▶ | $vars{ refaddr($self) } = [map {blessed($_) ? $_ : RDF::Query::Node::Variable->new($_)} @vars]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 110 | } | ||||||||||||||||||||
| 111 | 21 | return $self; | |||||||||||||||||||
| 112 | } | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | =item C<< as_sparql >> | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | =cut | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | 2 | ▶ | sub as_sparql { | ||||||||||||||||||
|
Subroutine
as_sparql: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 119 | 2 | my $self = shift; | |||||||||||||||||||
| 120 | 2 | return $self->name; | |||||||||||||||||||
| 121 | } | ||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | =item C<< referenced_variables >> | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | =cut | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | 0 | ▶ | sub referenced_variables { | ||||||||||||||||||
|
Subroutine
referenced_variables: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 128 | 0 | my $self = shift; | |||||||||||||||||||
| 129 | 0 | ▶ | my @vars = map { blessed($_) ? $_->name : $_ } @{ $vars{ refaddr($self) } || [] }; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$vars{builtin::refaddr($self)} || []
MC/DC0%0/1
$vars{builtin::refaddr($self)} || []
$vars{builtin::refaddr($self)}
Truth table0%0/2
A
A= $vars{builtin::refaddr($self)}
| |||||||||||||||||||||
| 130 | 0 | return RDF::Query::_uniq(@vars); | |||||||||||||||||||
| 131 | } | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | 0 | ▶ | sub nonaggregated_referenced_variables { | ||||||||||||||||||
|
Subroutine
nonaggregated_referenced_variables: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 134 | 0 | return; | |||||||||||||||||||
| 135 | } | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | 21 | ▶ | sub DESTROY { | ||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 138 | 21 | my $self = shift; | |||||||||||||||||||
| 139 | 21 | delete $vars{ refaddr($self) }; | |||||||||||||||||||
| 140 | } | ||||||||||||||||||||
| 141 | } | ||||||||||||||||||||
| 142 | |||||||||||||||||||||
| 143 | =end private | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | =cut | ||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | 36 | 1; | |||||||||||||||||||
| 148 | |||||||||||||||||||||
| 149 | __END__ | ||||||||||||||||||||