File Coverage

blib/lib/RDF/Core/Literal.pm
Criterion Covered Total %
statement 6 22 27.2
branch 0 8 0.0
condition 0 9 0.0
subroutine 2 9 22.2
pod 7 7 100.0
total 15 55 27.2


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::Literal;
35              
36 1     1   711 use strict;
  1         2  
  1         49  
37              
38             require Exporter;
39              
40             our @ISA = qw(RDF::Core::Node);
41              
42 1     1   5 use Carp;
  1         2  
  1         366  
43             require RDF::Core::Node;
44              
45              
46             sub new {
47 0     0 1   my ($pkg, $value, $lang, $datatype)=@_;
48 0   0       $pkg = ref $pkg || $pkg;
49 0           my $self={};
50              
51 0 0         $self->{_value} = defined $value ? $value : '';
52             # $self->{_lang} = $lang;
53             # $self->{_datatype} = $datatype;
54 0 0         $self->{_lang} = defined $lang ? $lang : '';
55 0 0         $self->{_datatype} = defined $datatype ? $datatype : '';
56 0           bless $self,$pkg;
57             }
58             sub getValue {
59 0     0 1   return $_[0]->{_value};
60             }
61             sub getLang {
62 0     0 1   return $_[0]->{_lang};
63             }
64             sub getDatatype {
65 0     0 1   return $_[0]->{_datatype};
66             }
67             sub equals {
68 0     0 1   my ($self, $node) = @_;
69 0 0 0       $node = new RDF::Core::Literal($node)
70             unless ref $node && $node->isa("RDF::Core::Node");
71 0   0       return $node->isLiteral
72             && ($node->getValue eq $self->getValue)
73             && (!$node->getLang && !$self->getLang
74             || uc($node->getLang) eq uc($self->getLang))
75             && (!$node->getDatatype && !$self->getDatatype
76             || $node->getDatatype eq $self->getDatatype);
77             }
78             #Override inherited method
79             sub getLabel {
80 0     0 1   return $_[0]->getValue;
81             }
82             sub clone {
83 0     0 1   my $self = shift;
84 0           return $self->new($self->{_value}, $self->{_lang}, $self->{_datatype});
85             }
86             1;
87             __END__