File Coverage

blib/lib/ODO/Ontology/ObjectWriter/PropertiesContainer.pm
Criterion Covered Total %
statement 15 36 41.6
branch 0 6 0.0
condition n/a
subroutine 5 8 62.5
pod 2 3 66.6
total 22 53 41.5


line stmt bran cond sub pod time code
1             #
2             # Copyright (c) 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/Ontology/ObjectWriter/PropertiesContainer.pm,v $
10             # Created by: Stephen Evanchik( evanchik@us.ibm.com )
11             # Created on: 11/28/2006
12             # Revision: $Id: PropertiesContainer.pm,v 1.2 2009-11-25 17:58:26 ubuntu Exp $
13             #
14             # Contributors:
15             # IBM Corporation - initial API and implementation
16             #
17             package ODO::Ontology::ObjectWriter::PropertiesContainer;
18              
19 2     2   12 use strict;
  2         4  
  2         67  
20 2     2   11 use warnings;
  2         4  
  2         49  
21              
22 2     2   1143 use ODO::Ontology::ObjectWriter::AccessorMethod;
  2         6  
  2         109  
23              
24 2     2   1413 use vars qw /$VERSION/;
  2         5  
  2         153  
25             $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /: (\d+)\.(\d+)/;
26              
27 2     2   10 use base qw/ODO::Ontology::ObjectWriter/;
  2         5  
  2         968  
28              
29             our @METHODS = qw/packageName w ISA properties propertyContainerAccessorFilename/;
30             our $PROPERTY_CONTAINER_NAME = 'PropertiesContainer';
31              
32             __PACKAGE__->mk_accessors(@METHODS);
33              
34             =head1 NAME
35              
36             =head1 SYNOPSIS
37              
38             =head1 DESCRIPTION
39              
40             =head1 CONSTRUCTOR
41              
42             =head1 METHODS
43              
44             =over
45              
46             =item serialize( [ %parameters ] )
47              
48             =cut
49              
50             sub serialize {
51 0     0 1   my $self = shift;
52              
53 0           my $propertiesContainerData = {
54             packageName=> $self->packageName(),
55             methods=> $self->serializeAccessorMethods(),
56             variables=> [],
57             };
58            
59 0 0         if($self->ISA()) {
60 0           $propertiesContainerData->{'ISA'} = $self->ISA();
61 0           push @{ $propertiesContainerData->{'variables'} }, '@ISA';
  0            
62             }
63            
64 0           return $self->ODO::Ontology::ObjectWriter::serialize(template_data=> $propertiesContainerData);
65             }
66              
67              
68             sub serializeAccessorMethods {
69 0     0 0   my $self = shift;
70            
71 0           my @accessorMethods;
72 0           foreach my $p (@{ $self->properties() }) {
  0            
73 0           push @accessorMethods, ODO::Ontology::ObjectWriter::AccessorMethod->new(%{ $p }, template_filename=> $self->propertyContainerAccessorFilename())->serialize();
  0            
74             }
75 0           return \@accessorMethods;
76             }
77              
78              
79             sub init {
80 0     0 1   my ($self, $config) = @_;
81 0           $self = $self->SUPER::init($config);
82              
83 0           $self->properties([]);
84            
85 0           $self->params($config, @METHODS);
86            
87            
88             # Default tempate filenames
89 0 0         $self->template_filename('ODO/Ontology/Templates/PropertyContainer.tt')
90             unless(defined($config->{'template_filename'}));
91            
92 0 0         $self->propertyContainerAccessorFilename('ODO/Ontology/Templates/PropertyAccessorMethod.tt')
93             unless(defined($config->{'propertyContainerAccessorFilename'}));
94            
95 0           return $self;
96             }
97              
98              
99             =back
100              
101             =head1 COPYRIGHT
102              
103             Copyright (c) 2006 IBM Corporation.
104              
105             All rights reserved. This program and the accompanying materials
106             are made available under the terms of the Eclipse Public License v1.0
107             which accompanies this distribution, and is available at
108             http://www.eclipse.org/legal/epl-v10.html
109              
110             =cut
111              
112              
113             1;
114              
115             __END__