line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
RDF::Query::Functions::Jena - Jena/ARQ work-alike functions |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 VERSION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This document describes RDF::Query::Functions::Jena version 2.916. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Defines the following functions: |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=over |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=item * java:com.hp.hpl.jena.query.function.library.langeq |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=item * java:com.hp.hpl.jena.query.function.library.listMember |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=item * java:com.hp.hpl.jena.query.function.library.now |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=item * java:com.hp.hpl.jena.query.function.library.sha1sum |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=back |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package RDF::Query::Functions::Jena; |
28
|
|
|
|
|
|
|
|
29
|
35
|
|
|
35
|
|
56559
|
use strict; |
|
35
|
|
|
|
|
92
|
|
|
35
|
|
|
|
|
942
|
|
30
|
35
|
|
|
35
|
|
191
|
use warnings; |
|
35
|
|
|
|
|
78
|
|
|
35
|
|
|
|
|
998
|
|
31
|
35
|
|
|
35
|
|
189
|
use Log::Log4perl; |
|
35
|
|
|
|
|
77
|
|
|
35
|
|
|
|
|
275
|
|
32
|
|
|
|
|
|
|
our ($VERSION, $l); |
33
|
|
|
|
|
|
|
BEGIN { |
34
|
35
|
|
|
35
|
|
3015
|
$l = Log::Log4perl->get_logger("rdf.query.functions.jena"); |
35
|
35
|
|
|
|
|
15160
|
$VERSION = '2.916'; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
35
|
|
|
35
|
|
230
|
use Digest::SHA qw(sha1_hex); |
|
35
|
|
|
|
|
83
|
|
|
35
|
|
|
|
|
2124
|
|
39
|
35
|
|
|
35
|
|
217
|
use I18N::LangTags; |
|
35
|
|
|
|
|
74
|
|
|
35
|
|
|
|
|
1586
|
|
40
|
35
|
|
|
35
|
|
192
|
use Scalar::Util qw(blessed reftype refaddr looks_like_number); |
|
35
|
|
|
|
|
67
|
|
|
35
|
|
|
|
|
24198
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=begin private |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item C<< install >> |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Documented in L<RDF::Query::Functions>. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=end private |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub install { |
53
|
|
|
|
|
|
|
RDF::Query::Functions->install_function( |
54
|
|
|
|
|
|
|
["http://jena.hpl.hp.com/ARQ/function#sha1sum", "java:com.hp.hpl.jena.query.function.library.sha1sum"], |
55
|
|
|
|
|
|
|
sub { |
56
|
2
|
|
|
2
|
|
7
|
my $query = shift; |
57
|
2
|
|
|
|
|
4
|
my $node = shift; |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
4
|
my $value; |
60
|
2
|
100
|
|
|
|
21
|
if ($node->isa('RDF::Query::Node::Literal')) { |
|
|
50
|
|
|
|
|
|
61
|
1
|
|
|
|
|
5
|
$value = $node->literal_value; |
62
|
|
|
|
|
|
|
} elsif ($node->isa('RDF::Query::Node::Resource')) { |
63
|
1
|
|
|
|
|
4
|
$value = $node->uri_value; |
64
|
|
|
|
|
|
|
} else { |
65
|
0
|
|
|
|
|
0
|
throw RDF::Query::Error::TypeError -text => "jena:sha1sum called without a literal or resource"; |
66
|
|
|
|
|
|
|
} |
67
|
2
|
|
|
|
|
50
|
my $hash = sha1_hex( $value ); |
68
|
2
|
|
|
|
|
11
|
return RDF::Query::Node::Literal->new( $hash ); |
69
|
|
|
|
|
|
|
} |
70
|
35
|
|
|
35
|
1
|
362
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
RDF::Query::Functions->install_function( |
73
|
|
|
|
|
|
|
["http://jena.hpl.hp.com/ARQ/function#now", "java:com.hp.hpl.jena.query.function.library.now"], |
74
|
|
|
|
|
|
|
sub { |
75
|
2
|
|
|
2
|
|
5
|
my $query = shift; |
76
|
2
|
|
|
|
|
15
|
my $dt = DateTime->now(); |
77
|
2
|
50
|
|
|
|
604
|
my $f = ref($query) ? $query->dateparser : DateTime::Format::W3CDTF->new; |
78
|
2
|
|
|
|
|
18
|
my $value = $f->format_datetime( $dt ); |
79
|
2
|
|
|
|
|
112
|
return RDF::Query::Node::Literal->new( $value, undef, 'http://www.w3.org/2001/XMLSchema#dateTime' ); |
80
|
|
|
|
|
|
|
} |
81
|
35
|
|
|
|
|
341
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
RDF::Query::Functions->install_function( |
84
|
|
|
|
|
|
|
["http://jena.hpl.hp.com/ARQ/function#langeq", "java:com.hp.hpl.jena.query.function.library.langeq"], |
85
|
|
|
|
|
|
|
sub { |
86
|
2
|
|
|
2
|
|
5
|
my $query = shift; |
87
|
2
|
|
|
|
|
3
|
my $node = shift; |
88
|
2
|
|
|
|
|
5
|
my $lang = shift; |
89
|
2
|
|
|
|
|
8
|
my $litlang = $node->literal_value_language; |
90
|
2
|
|
|
|
|
14
|
my $match = $lang->literal_value; |
91
|
2
|
100
|
|
|
|
17
|
return I18N::LangTags::is_dialect_of( $litlang, $match ) |
92
|
|
|
|
|
|
|
? RDF::Query::Node::Literal->new('true', undef, 'http://www.w3.org/2001/XMLSchema#boolean') |
93
|
|
|
|
|
|
|
: RDF::Query::Node::Literal->new('false', undef, 'http://www.w3.org/2001/XMLSchema#boolean'); |
94
|
|
|
|
|
|
|
} |
95
|
35
|
|
|
|
|
297
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
RDF::Query::Functions->install_function( |
98
|
|
|
|
|
|
|
["http://jena.hpl.hp.com/ARQ/function#listMember", "java:com.hp.hpl.jena.query.function.library.listMember"], |
99
|
|
|
|
|
|
|
sub { |
100
|
3
|
|
|
3
|
|
6
|
my $query = shift; |
101
|
|
|
|
|
|
|
|
102
|
3
|
|
|
|
|
5
|
my $list = shift; |
103
|
3
|
|
|
|
|
4
|
my $value = shift; |
104
|
|
|
|
|
|
|
|
105
|
3
|
|
|
|
|
46
|
my $first = RDF::Query::Node::Resource->new( 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first' ); |
106
|
3
|
|
|
|
|
52
|
my $rest = RDF::Query::Node::Resource->new( 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest' ); |
107
|
|
|
|
|
|
|
|
108
|
3
|
|
|
|
|
38
|
my $result; |
109
|
3
|
|
|
|
|
39
|
LIST: while ($list) { |
110
|
6
|
50
|
33
|
|
|
98
|
if ($list->is_resource and $list->uri_value eq 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil') { |
111
|
0
|
|
|
|
|
0
|
return RDF::Query::Node::Literal->new('false', undef, 'http://www.w3.org/2001/XMLSchema#boolean'); |
112
|
|
|
|
|
|
|
} else { |
113
|
6
|
|
|
|
|
76
|
my $stream = $query->model->get_statements( $list, $first, undef ); |
114
|
6
|
|
|
|
|
19845
|
while (my $stmt = $stream->next()) { |
115
|
6
|
|
|
|
|
675
|
my $member = $stmt->object; |
116
|
6
|
100
|
|
|
|
41
|
return RDF::Query::Node::Literal->new('true', undef, 'http://www.w3.org/2001/XMLSchema#boolean') if ($value->equal( $member )); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
3
|
|
|
|
|
119
|
my $stmt = $query->model->get_statements( $list, $rest, undef )->next(); |
120
|
3
|
50
|
|
|
|
10099
|
return RDF::Query::Node::Literal->new('false', undef, 'http://www.w3.org/2001/XMLSchema#boolean') unless ($stmt); |
121
|
|
|
|
|
|
|
|
122
|
3
|
|
|
|
|
11
|
my $tail = $stmt->object; |
123
|
3
|
50
|
|
|
|
23
|
if ($tail) { |
124
|
3
|
|
|
|
|
49
|
$list = $tail; |
125
|
3
|
|
|
|
|
54
|
next; #next LIST; |
126
|
|
|
|
|
|
|
} else { |
127
|
0
|
|
|
|
|
|
return RDF::Query::Node::Literal->new('false', undef, 'http://www.w3.org/2001/XMLSchema#boolean'); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
return RDF::Query::Node::Literal->new('false', undef, 'http://www.w3.org/2001/XMLSchema#boolean'); |
133
|
|
|
|
|
|
|
} |
134
|
35
|
|
|
|
|
359
|
); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__END__ |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Gregory Williams <gwilliams@cpan.org>. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |