line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright (c) 2004-2006 IBM Corporation. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# All rights reserved. This program and the accompanying materials |
5
|
|
|
|
|
|
|
# are made available under the terms of the Eclipse Public License v1.0 |
6
|
|
|
|
|
|
|
# which accompanies this distribution, and is available at |
7
|
|
|
|
|
|
|
# http://www.eclipse.org/legal/epl-v10.html |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# File: $Source: /var/lib/cvs/ODO/lib/ODO/Query/Simple.pm,v $ |
10
|
|
|
|
|
|
|
# Created by: Stephen Evanchik( evanchik@us.ibm.com ) |
11
|
|
|
|
|
|
|
# Created on: 10/05/2004 |
12
|
|
|
|
|
|
|
# Revision: $Id: Simple.pm,v 1.2 2009-11-25 17:53:53 ubuntu Exp $ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Contributors: |
15
|
|
|
|
|
|
|
# IBM Corporation - initial API and implementation |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
package ODO::Query::Simple; |
18
|
|
|
|
|
|
|
|
19
|
8
|
|
|
8
|
|
223000
|
use strict; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
342
|
|
20
|
8
|
|
|
8
|
|
46
|
use warnings; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
246
|
|
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
8
|
|
43
|
use vars qw /$VERSION/; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
750
|
|
23
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /: (\d+)\.(\d+)/; |
24
|
|
|
|
|
|
|
|
25
|
8
|
|
|
8
|
|
51
|
use base qw/ODO::Statement/; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
19261
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
ODO::Query::Simple - Simple single statement wildcard graph pattern matcher |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use ODO::Node; |
34
|
|
|
|
|
|
|
use ODO::Query::Simple; |
35
|
|
|
|
|
|
|
use ODO::Query::Simple::Result; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $s = ODO::Node::Resource->new('urn:lsid:testuri.org:ns:object:'); |
38
|
|
|
|
|
|
|
my $p = ODO::Node::Resource->new('http://testuri.org/predicate'); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $stmt = ODO::Query::Simple->new($s, $p, undef); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# ... $graph is an ODO::Graph |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Search for statements that match $s, $p, |
45
|
|
|
|
|
|
|
my $result_set = $graph->query($stmt); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
A simple single statement based graph pattern for searching. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 CONSTANTS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=over |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item $ALL_STATEMENTS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
our $ALL_STATEMENTS = ODO::Query::Simple->new(); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item new( [ [s=> $s ], [ p=> $p], [ o=> $o ] ] | [ $s, [ $p, [ $o ] ] ] ) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Creates a new L object with the specified $subject, $predicate, $object |
70
|
|
|
|
|
|
|
The $subject, $predicate, $object may be any combination of L, |
71
|
|
|
|
|
|
|
L, L, |
72
|
|
|
|
|
|
|
L (more generically, anything that conforms to L). |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
If any of the parameters $subject, $predicate, $object are undef, that node will become |
75
|
|
|
|
|
|
|
an L. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item equal( $statement ) |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Tests whether or not $self and $statement are the same statement, taking |
80
|
|
|
|
|
|
|
L nodes in to account. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub equal { |
85
|
986
|
|
|
986
|
1
|
1243
|
my ($self, $statement) = @_; |
86
|
|
|
|
|
|
|
|
87
|
986
|
50
|
|
|
|
2844
|
throw ODO::Exception::Parameter::Invalid(error=> 'Missing statement parameter, must be type ODO::Statement') |
88
|
|
|
|
|
|
|
unless(UNIVERSAL::isa($statement, 'ODO::Statement')); |
89
|
|
|
|
|
|
|
|
90
|
986
|
100
|
100
|
|
|
2260
|
return 1 |
|
|
|
66
|
|
|
|
|
91
|
|
|
|
|
|
|
if( $self->s()->equal($statement->s()) |
92
|
|
|
|
|
|
|
&& $self->p()->equal($statement->p()) |
93
|
|
|
|
|
|
|
&& $self->o()->equal($statement->o()) |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
954
|
|
|
|
|
3717
|
return 0; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub init { |
101
|
153
|
|
|
153
|
1
|
3329
|
my ($self, $config) = @_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# ANY nodes match everything |
104
|
153
|
|
66
|
|
|
497
|
my $s = $config->{'s'} || $ODO::Node::ANY; |
105
|
153
|
|
66
|
|
|
433
|
my $p = $config->{'p'} || $ODO::Node::ANY; |
106
|
153
|
|
66
|
|
|
2056
|
my $o = $config->{'o'} || $ODO::Node::ANY; |
107
|
|
|
|
|
|
|
|
108
|
153
|
|
|
|
|
475
|
$self->s($s); |
109
|
153
|
|
|
|
|
1366
|
$self->p($p); |
110
|
153
|
|
|
|
|
969
|
$self->o($o); |
111
|
|
|
|
|
|
|
|
112
|
153
|
|
|
|
|
863
|
return $self; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=back |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
IBM Corporation |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SEE ALSO |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L, L, L |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Copyright (c) 2004-2006 IBM Corporation. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
All rights reserved. This program and the accompanying materials |
131
|
|
|
|
|
|
|
are made available under the terms of the Eclipse Public License v1.0 |
132
|
|
|
|
|
|
|
which accompanies this distribution, and is available at |
133
|
|
|
|
|
|
|
http://www.eclipse.org/legal/epl-v10.html |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__END__ |