Query/Node/Blank.pm

filter: Statementstmt 93.3% 56 / 60 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 18 / 20 Podpod 100% 4 / 4 totaltotal 90.6% 87 / 96 CC 7 SCAR 8.5
CC
7
Cov
90%
_cmp
6.1
__ANON__
2.0
new
2.0
CRAP 2.3
« Query/Plan/Limit.pm ↑ Summary Query/Algebra/Sort.pm »
1 # RDF::Query::Node::Blank
2 # -----------------------------------------------------------------------------
3  
4 =head1 NAME
5  
6 RDF::Query::Node::Blank - RDF Node class for blank nodes
7  
8 =head1 VERSION
9  
10 This document describes RDF::Query::Node::Blank version 2.919.
11  
12 =head1 METHODS
13  
14 Beyond the methods documented below, this class inherits methods from the
15 L<RDF::Query::Node> and L<RDF::Trine::Node::Blank> classes.
16  
17 =over 4
18  
19 =cut
20  
21 package RDF::Query::Node::Blank;
22  
23 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 36 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 36 ▶use base qw(RDF::Query::Node RDF::Trine::Node::Blank);
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 36 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 36 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
30 36 ▶use Carp qw(carp croak confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 ######################################################################
33  
34 36 our ($VERSION);
35 36 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
36 36 $VERSION = '2.919';
37 }
38  
39 ######################################################################
40  
41 36 ▶use overload '<=>' => \&_cmp,
Subroutine BEGIN: called CC=1 SCAR=0.0
42 'cmp' => \&_cmp,
43 2 ▶ '<' => sub { _cmp(@_[0,1]) == -1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
44 1 ▶ '>' => sub { _cmp(@_[0,1]) == 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
45 1 ▶ '!=' => sub { _cmp(@_[0,1]) != 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
46 1 ▶ '==' => sub { _cmp(@_[0,1]) == 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
47 0 ▶ '+' => sub { $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 108 ▶ '""' => sub { $_[0]->sse },
Subroutine __ANON__: called CC=1 SCAR=0.0
49 36 ;
50  
51 6 ▶sub _cmp {
Subroutine _cmp: called CC=6 SCAR=18.1
52 6 my $nodea = shift;
53 6 my $nodeb = shift;
54 6 my $l = Log::Log4perl->get_logger("rdf.query.node.blank");
55 6 $l->debug("blank comparison: " . Dumper($nodea, $nodeb));
56 6 ▶ return 1 unless blessed($nodeb);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($nodeb) 0 6 6
57 6 ▶ return -1 if ($nodeb->isa('RDF::Trine::Node::Nil'));
Branch: 1 branch
BranchTrueFalseTotal
if $nodeb->isa("RDF::Trine::Node::Nil") 0 6 6
58 6 ▶ return -1 if ($nodeb->isa('RDF::Query::Node::Literal'));
Branch: 1 branch
BranchTrueFalseTotal
if $nodeb->isa("RDF::Query::Node::Literal") 1 5 6
59 5 ▶ return -1 if ($nodeb->isa('RDF::Query::Node::Resource'));
Branch: 1 branch
BranchTrueFalseTotal
if $nodeb->isa("RDF::Query::Node::Resource") 1 4 5
60 4 ▶ return 1 unless ($nodeb->isa('RDF::Query::Node::Blank'));
Branch: 1 branch
BranchTrueFalseTotal
unless $nodeb->isa("RDF::Query::Node::Blank") 0 4 4
61 4 my $cmp = $nodea->blank_identifier cmp $nodeb->blank_identifier;
62 4 $l->debug("-> $cmp");
63 4 return $cmp;
64 }
65  
66 =item C<< new ( [ $name ] ) >>
67  
68 Returns a new Blank node object. If C<< $name >> is supplied, it will be used as
69 the blank node identifier. Otherwise a time-based identifier will be generated
70 and used.
71  
72 =cut
73  
74 143 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
75 143 my $class = shift;
76 143 my $name = shift;
77 143 ▶ unless (defined($name)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 3 140 143
78 3 $name = 'r' . time() . 'r' . $RDF::Trine::Node::Blank::COUNTER++;
79 }
80 143 return $class->_new( $name );
81 }
82  
83 =item C<< as_sparql >>
84  
85 Returns the SPARQL string for this node.
86  
87 =cut
88  
89 8 ▶sub as_sparql {
Subroutine as_sparql: called CC=1 SCAR=0.0
Pod documented
90 8 my $self = shift;
91 8 return $self->sse;
92 }
93  
94 =item C<< as_hash >>
95  
96 Returns the query as a nested set of plain data structures (no objects).
97  
98 =cut
99  
100 0 ▶sub as_hash {
Subroutine as_hash: not called CC=1 SCAR=6.9
Pod documented
101 0 my $self = shift;
102 0 my $context = shift;
103 return {
104 0 type => 'node',
105 blank => $self->blank_identifier,
106 };
107 }
108  
109 =item C<< make_distinguished_variable >>
110  
111 Returns a new variable based on this blank node.
112  
113 =cut
114  
115 38 ▶sub make_distinguished_variable {
Subroutine make_distinguished_variable: called CC=1 SCAR=0.0
Pod documented
116 38 my $self = shift;
117 38 my $id = $self->blank_identifier;
118 38 my $name = '__ndv_' . $id;
119 38 my $var = RDF::Query::Node::Variable->new( $name );
120 38 return $var;
121 }
122  
123  
124 36 1;
125  
126 __END__
« Query/Plan/Limit.pm ↑ Summary Query/Algebra/Sort.pm »