File Coverage

blib/lib/ODO/RDFS/Literal.pm
Criterion Covered Total %
statement 24 62 38.7
branch 0 10 0.0
condition 0 3 0.0
subroutine 8 13 61.5
pod 2 4 50.0
total 34 92 36.9


line stmt bran cond sub pod time code
1             package ODO::RDFS::Literal;
2              
3 1     1   4 use strict;
  1         1  
  1         26  
4 1     1   4 use warnings;
  1         1  
  1         20  
5 1     1   4 use vars qw( @ISA );
  1         1  
  1         31  
6 1     1   4 use vars qw /$VERSION/;
  1         1  
  1         60  
7             $VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /: (\d+)\.(\d+)/;
8 1     1   4 use ODO;
  1         1  
  1         29  
9 1     1   4 use ODO::Query::Simple;
  1         1  
  1         28  
10 1     1   4 use ODO::Statement::Group;
  1         1  
  1         22  
11 1     1   5 use ODO::RDFS::Resource;
  1         6  
  1         408  
12              
13             @ISA = ( 'ODO::RDFS::Resource', );
14              
15             #
16             # Description: The class of literal values, eg. textual strings and integers.
17             #
18             # Schema URI: http://www.w3.org/2000/01/rdf-schema#
19             #
20             sub new {
21 0     0 1   my $self = shift;
22 0           my ($resource, $graph, %properties) = @_;
23            
24 0           $self = $self->SUPER::new(@_);
25            
26             return undef
27 0 0         unless(ref $self);
28            
29 0           $self->propertyContainerName( 'ODO::RDFS::Literal::PropertiesContainer' );
30 0           $self->properties(bless {}, 'ODO::RDFS::Literal::PropertiesContainer');
31              
32 0           $self->properties()->{'parent'} = $self;
33              
34              
35 0           return $self;
36             }
37              
38             sub queryString {
39 0     0 0   return '(?subj, rdf:type, )';
40             }
41              
42             sub objectURI {
43 0     0 0   return 'http://www.w3.org/2000/01/rdf-schema#Literal';
44             }
45              
46             sub value {
47 0     0 1   my $self = shift;
48            
49 0 0         return $self->subject()
50             if(UNIVERSAL::isa($self->subject(), 'ODO::Node::Literal'));
51            
52 0           return $self->__to_statement_array();
53             }
54              
55             sub __to_statement_array {
56 0     0     my $self = shift;
57            
58 0           my $statements = [];
59            
60 0           foreach my $my_super (@ISA) {
61            
62             next
63 0 0         unless(UNIVERSAL::can($my_super, '__to_statement_array'));
64            
65 0           my $super_func = "${my_super}::__to_statement_array";
66 0           push @{ $statements }, @{ $self->$super_func() };
  0            
  0            
67             }
68            
69 0           my %properties = (''=> '',);
70            
71 0           foreach my $propertyName (keys(%properties)) {
72              
73             next
74 0 0 0       unless($propertyName && $propertyName ne '');
75            
76 0           my $property = $self->properties()->$propertyName();
77            
78 0           foreach my $p (@{ $property }) {
  0            
79 0           my $p_value = $p->value();
80            
81 0           my $property_uri = ODO::Node::Resource->new($properties{$propertyName}->objectURI() );
82 0 0         if(UNIVERSAL::isa($p_value, 'ODO::Node::Literal')) {
83 0           push @{ $statements }, ODO::Statement->new($self->subject(), $property_uri, $p_value);
  0            
84             }
85             else {
86 0           push @{ $statements }, ODO::Statement->new($self->subject(), $property_uri, $p->subject());
  0            
87 0           push @{ $statements }, @{ $p_value };
  0            
  0            
88             }
89             }
90             }
91            
92 0           return $statements;
93             }
94              
95             1;