line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RDF::Trine::Node::Blank |
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Trine::Node::Blank - RDF Node class for blank nodes |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Trine::Node::Blank version 1.018 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package RDF::Trine::Node::Blank; |
15
|
|
|
|
|
|
|
|
16
|
68
|
|
|
68
|
|
379
|
use strict; |
|
68
|
|
|
|
|
128
|
|
|
68
|
|
|
|
|
1531
|
|
17
|
68
|
|
|
68
|
|
292
|
use warnings; |
|
68
|
|
|
|
|
122
|
|
|
68
|
|
|
|
|
1412
|
|
18
|
68
|
|
|
68
|
|
300
|
no warnings 'redefine'; |
|
68
|
|
|
|
|
127
|
|
|
68
|
|
|
|
|
1696
|
|
19
|
68
|
|
|
68
|
|
320
|
use base qw(RDF::Trine::Node); |
|
68
|
|
|
|
|
130
|
|
|
68
|
|
|
|
|
3783
|
|
20
|
|
|
|
|
|
|
|
21
|
68
|
|
|
68
|
|
363
|
use Data::Dumper; |
|
68
|
|
|
|
|
142
|
|
|
68
|
|
|
|
|
2572
|
|
22
|
68
|
|
|
68
|
|
355
|
use Scalar::Util qw(blessed); |
|
68
|
|
|
|
|
126
|
|
|
68
|
|
|
|
|
2488
|
|
23
|
68
|
|
|
68
|
|
342
|
use Carp qw(carp croak confess); |
|
68
|
|
|
|
|
146
|
|
|
68
|
|
|
|
|
3996
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
###################################################################### |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our ($VERSION); |
28
|
|
|
|
|
|
|
BEGIN { |
29
|
68
|
|
|
68
|
|
2696
|
$VERSION = '1.018'; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
###################################################################### |
33
|
|
|
|
|
|
|
|
34
|
4203
|
|
|
4203
|
|
12411
|
use overload '""' => sub { $_[0]->sse }, |
35
|
68
|
|
|
68
|
|
385
|
; |
|
68
|
|
|
|
|
139
|
|
|
68
|
|
|
|
|
504
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 METHODS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Beyond the methods documented below, this class inherits methods from the |
40
|
|
|
|
|
|
|
L<RDF::Trine::Node> class. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over 4 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item C<new ( $name )> |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Returns a new Blank structure. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $COUNTER = 0; |
53
|
|
|
|
|
|
|
sub new { |
54
|
1188
|
|
|
1188
|
1
|
3788
|
my $class = shift; |
55
|
1188
|
|
|
|
|
2108
|
my $name = shift; |
56
|
1188
|
100
|
|
|
|
3052
|
unless (defined($name)) { |
57
|
428
|
|
|
|
|
1391
|
$name = 'r' . time() . 'r' . $COUNTER++; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
1188
|
|
|
|
|
4327
|
my $r_PN_CHARS_U = qr/[_A-Za-z_\x{00C0}-\x{00D6}\x{00D8}-\x{00F6}\x{00F8}-\x{02FF}\x{0370}-\x{037D}\x{037F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}]/; |
61
|
1188
|
|
|
|
|
7507
|
my $r_PN_CHARS = qr"${r_PN_CHARS_U}|[-0-9\x{00B7}\x{0300}-\x{036F}\x{203F}-\x{2040}]"; |
62
|
1188
|
|
|
|
|
8710
|
my $r_bnode_id = qr"(?:${r_PN_CHARS_U}|[0-9])((${r_PN_CHARS}|[.])*${r_PN_CHARS})?"; |
63
|
1188
|
100
|
|
|
|
9833
|
unless ($name =~ /^${r_bnode_id}$/o) { |
64
|
1
|
|
|
|
|
16
|
throw RDF::Trine::Error::SerializationError -text => "Bad blank node identifier: $name"; |
65
|
|
|
|
|
|
|
} |
66
|
1187
|
|
|
|
|
3700
|
return $class->_new( $name ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _new { |
70
|
1187
|
|
|
1187
|
|
2206
|
my $class = shift; |
71
|
1187
|
|
|
|
|
1993
|
my $name = shift; |
72
|
1187
|
|
|
|
|
7572
|
return bless( [ 'BLANK', $name ], $class ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item C<< blank_identifier >> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Returns the identifier of the blank node. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub blank_identifier { |
82
|
16786
|
|
|
16786
|
1
|
26846
|
my $self = shift; |
83
|
16786
|
|
|
|
|
48186
|
return $self->[1]; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item C<< value >> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns the blank identifier. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub value { |
93
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
94
|
0
|
|
|
|
|
0
|
return $self->blank_identifier; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item C<< sse >> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns the SSE string for this blank node. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub sse { |
104
|
7399
|
|
|
7399
|
1
|
11313
|
my $self = shift; |
105
|
7399
|
|
|
|
|
14073
|
my $id = $self->blank_identifier; |
106
|
7399
|
|
|
|
|
24319
|
return qq(_:${id}); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item C<< as_ntriples >> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns the node in a string form suitable for NTriples serialization. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub as_ntriples { |
116
|
37
|
|
|
37
|
1
|
70
|
my $self = shift; |
117
|
37
|
|
|
|
|
96
|
my $id = $self->blank_identifier; |
118
|
37
|
|
|
|
|
173
|
return qq(_:${id}); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item C<< as_string >> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns a string representation of the node. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub as_string { |
128
|
5955
|
|
|
5955
|
1
|
9798
|
my $self = shift; |
129
|
5955
|
|
|
|
|
12141
|
return '(' . $self->blank_identifier . ')'; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item C<< type >> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Returns the type string of this node. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub type { |
139
|
2497
|
|
|
2497
|
1
|
5553
|
return 'BLANK'; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item C<< equal ( $node ) >> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Returns true if the two nodes are equal, false otherwise. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub equal { |
149
|
314
|
|
|
314
|
1
|
592
|
my $self = shift; |
150
|
314
|
|
|
|
|
487
|
my $node = shift; |
151
|
314
|
100
|
100
|
|
|
2258
|
return 0 unless (blessed($node) and $node->isa('RDF::Trine::Node::Blank')); |
152
|
194
|
|
|
|
|
503
|
return ($self->blank_identifier eq $node->blank_identifier); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# called to compare two nodes of the same type |
156
|
|
|
|
|
|
|
sub _compare { |
157
|
508
|
|
|
508
|
|
776
|
my $a = shift; |
158
|
508
|
|
|
|
|
763
|
my $b = shift; |
159
|
508
|
|
|
|
|
935
|
return ($a->blank_identifier cmp $b->blank_identifier); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
__END__ |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 BUGS |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
171
|
|
|
|
|
|
|
at L<https://github.com/kasei/perlrdf/issues>. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 AUTHOR |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 COPYRIGHT |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Copyright (c) 2006-2012 Gregory Todd Williams. This |
180
|
|
|
|
|
|
|
program is free software; you can redistribute it and/or modify it under |
181
|
|
|
|
|
|
|
the same terms as Perl itself. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |