| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# The contents of this file are subject to the Mozilla Public |
|
3
|
|
|
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file |
|
4
|
|
|
|
|
|
|
# except in compliance with the License. You may obtain a copy of |
|
5
|
|
|
|
|
|
|
# the License at http://www.mozilla.org/MPL/ |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Software distributed under the License is distributed on an "AS |
|
8
|
|
|
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
9
|
|
|
|
|
|
|
# implied. See the License for the specific language governing |
|
10
|
|
|
|
|
|
|
# rights and limitations under the License. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# The Original Code is the RDF::Core module |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# The Initial Developer of the Original Code is Ginger Alliance Ltd. |
|
15
|
|
|
|
|
|
|
# Portions created by Ginger Alliance are |
|
16
|
|
|
|
|
|
|
# Copyright (C) 2001 Ginger Alliance Ltd. |
|
17
|
|
|
|
|
|
|
# All Rights Reserved. |
|
18
|
|
|
|
|
|
|
# |
|
19
|
|
|
|
|
|
|
# Contributor(s): |
|
20
|
|
|
|
|
|
|
# |
|
21
|
|
|
|
|
|
|
# Alternatively, the contents of this file may be used under the |
|
22
|
|
|
|
|
|
|
# terms of the GNU General Public License Version 2 or later (the |
|
23
|
|
|
|
|
|
|
# "GPL"), in which case the provisions of the GPL are applicable |
|
24
|
|
|
|
|
|
|
# instead of those above. If you wish to allow use of your |
|
25
|
|
|
|
|
|
|
# version of this file only under the terms of the GPL and not to |
|
26
|
|
|
|
|
|
|
# allow others to use your version of this file under the MPL, |
|
27
|
|
|
|
|
|
|
# indicate your decision by deleting the provisions above and |
|
28
|
|
|
|
|
|
|
# replace them with the notice and other provisions required by |
|
29
|
|
|
|
|
|
|
# the GPL. If you do not delete the provisions above, a recipient |
|
30
|
|
|
|
|
|
|
# may use your version of this file under either the MPL or the |
|
31
|
|
|
|
|
|
|
# GPL. |
|
32
|
|
|
|
|
|
|
# |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
package RDF::Core::Resource; |
|
35
|
|
|
|
|
|
|
|
|
36
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
115
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
require Exporter; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our @ISA = qw(RDF::Core::Node); |
|
42
|
|
|
|
|
|
|
|
|
43
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
1018
|
|
|
44
|
|
|
|
|
|
|
require RDF::Core::Node; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new { |
|
47
|
0
|
|
|
0
|
1
|
|
my $pkg = shift; |
|
48
|
0
|
|
0
|
|
|
|
$pkg = ref $pkg || $pkg; |
|
49
|
0
|
|
|
|
|
|
my $self = {}; |
|
50
|
0
|
|
|
|
|
|
my $namespace; |
|
51
|
|
|
|
|
|
|
my $localValue; |
|
52
|
0
|
|
|
|
|
|
bless $self,$pkg; |
|
53
|
0
|
0
|
|
|
|
|
if (@_ gt 1) { |
|
54
|
|
|
|
|
|
|
#more then one parameters is interpreted as ($namespace,$localValue) pair |
|
55
|
0
|
|
|
|
|
|
($namespace,$localValue) = @_; |
|
56
|
0
|
0
|
|
|
|
|
croak "Resource's namespace must be defined" |
|
57
|
|
|
|
|
|
|
unless defined $namespace; |
|
58
|
0
|
0
|
|
|
|
|
$localValue = '' |
|
59
|
|
|
|
|
|
|
unless defined $localValue; |
|
60
|
|
|
|
|
|
|
} else { |
|
61
|
|
|
|
|
|
|
#one parameter is URI |
|
62
|
0
|
|
|
|
|
|
my ($URI) = @_; |
|
63
|
0
|
0
|
|
|
|
|
croak "Resource's URI must be defined" |
|
64
|
|
|
|
|
|
|
unless defined $URI; |
|
65
|
0
|
|
|
|
|
|
$self->_resolveURI($URI,\$namespace,\$localValue); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
0
|
|
|
|
|
|
$self->{_namespace} = $namespace; |
|
68
|
0
|
|
|
|
|
|
$self->{_localValue} = $localValue; |
|
69
|
0
|
|
|
|
|
|
$self->{_uri} = $namespace.$localValue; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $self; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
sub getNamespace { |
|
74
|
0
|
|
|
0
|
1
|
|
return $_[0]->{_namespace}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
sub getLocalValue { |
|
77
|
0
|
|
|
0
|
1
|
|
return $_[0]->{_localValue}; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
sub getURI { |
|
80
|
0
|
|
|
0
|
1
|
|
return $_[0]->{_uri}; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
#Override inherited method |
|
83
|
|
|
|
|
|
|
sub getLabel { |
|
84
|
0
|
|
|
0
|
1
|
|
return $_[0]->getURI; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
sub clone { |
|
87
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
88
|
0
|
|
|
|
|
|
return $self->new($self->{_namespace}, $self->{_localValue}); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub equals { |
|
92
|
0
|
|
|
0
|
1
|
|
my ($self, $other) = @_; |
|
93
|
0
|
0
|
0
|
|
|
|
$other = new RDF::Core::Resource($other) |
|
94
|
|
|
|
|
|
|
unless ref $other && $other->isa("RDF::Core::Node"); |
|
95
|
0
|
|
0
|
|
|
|
return !$self->isLiteral && $self->getURI eq $other->getURI; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _resolveURI { |
|
99
|
0
|
|
|
0
|
|
|
my ($self,$URI,$ns,$lv)=@_; |
|
100
|
0
|
0
|
|
|
|
|
if ($URI=~/(^.*[\/#:])([a-zA-Z_][^\/#:]*$)/) { |
|
101
|
0
|
|
|
|
|
|
$$ns = $1; |
|
102
|
0
|
|
|
|
|
|
$$lv = $2; |
|
103
|
|
|
|
|
|
|
} else { |
|
104
|
0
|
|
|
|
|
|
$$ns = $URI; |
|
105
|
0
|
|
|
|
|
|
$$lv = ''; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
|
110
|
|
|
|
|
|
|
__END__ |