File Coverage

blib/lib/Biblio/ILL/ISO/SEQUENCE_OF.pm
Criterion Covered Total %
statement 30 42 71.4
branch 1 2 50.0
condition 1 3 33.3
subroutine 7 9 77.7
pod 6 6 100.0
total 45 62 72.5


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::SEQUENCE_OF;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::SEQUENCE_OF
6              
7             =cut
8              
9 4     4   22 use Biblio::ILL::ISO::ILLASNtype;
  4         16  
  4         145  
10              
11 4     4   24 use Carp;
  4         9  
  4         426  
12              
13             =head1 VERSION
14              
15             Version 0.01
16              
17             =cut
18              
19             our $VERSION = '0.01';
20             #---------------------------------------------------------------------------
21             # Mods
22             # 0.01 - 2003.07.15 - original version
23             #---------------------------------------------------------------------------
24              
25             =head1 DESCRIPTION
26              
27             Biblio::ILL::ISO::SEQUENCE_OF is a derivation of Biblio::ILL::ISO::ILLASNtype.
28             It functions as a base class for any class that needs to handle sequence types.
29              
30             =head1 USES
31              
32             None.
33              
34             =head1 USED IN
35              
36             Biblio::ILL::ISO::AlreadyTriedListType
37             Biblio::ILL::ISO::ElectronicDeliveryServiceSequence
38             Biblio::ILL::ISO::ILLServiceTypeSequence
39             Biblio::ILL::ISO::LocationInfoSequence
40             Biblio::ILL::ISO::SendToListTypeSequence
41             Biblio::ILL::ISO::SupplyMediumInfoTypeSequence
42             Biblio::ILL::ISO::UnitsPerMediumTypeSequence
43              
44             =cut
45              
46 4     4   1965 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
47              
48             =head1 FROM THE ASN DEFINITION
49              
50             There is no ASN DEFINITION for SEQUENCE_OF. An ASN.1 element can be defined
51             as a SEQUENCE OF another element - it is simply a list.
52              
53             =cut
54              
55             #---------------------------------------------------------------
56             #
57             #---------------------------------------------------------------
58             =head1
59              
60             =head2 new( [ @objrefs ] )
61              
62             Creates a new SEQUENCE_OF object.
63             Expects either no paramaters, or a list of objects to be added to the list.
64              
65             =cut
66             sub new {
67 14     14 1 71 my $class = shift;
68 14         22 my $self = {};
69              
70 14         32 $self->{"SEQUENCE"} = [ ];
71              
72 14 50       33 if (@_) {
73 14         109 while ($objref = shift) {
74 16         20 push @{ $self->{"SEQUENCE"} }, $objref;
  16         68  
75             }
76             }
77 14   33     83 bless($self, ref($class) || $class);
78 14         46 return ($self);
79             }
80              
81              
82             #---------------------------------------------------------------
83             #
84             #---------------------------------------------------------------
85             =head1
86              
87             =head2 as_string( )
88              
89             Returns a stringified representation of the object.
90              
91             =cut
92             sub as_string {
93 0     0 1 0 my $self = shift;
94              
95 0         0 my $s = "SEQUENCE\n";
96 0         0 foreach $elem (@{ $self->{"SEQUENCE"} }) {
  0         0  
97 0         0 $s .= $elem->as_string();
98             }
99 0         0 return $s;
100             }
101              
102              
103             #---------------------------------------------------------------
104             #
105             #---------------------------------------------------------------
106             =head1
107              
108             =head2 as_pretty_string( )
109              
110             Returns a more-formatted stringified representation of the object.
111              
112             =cut
113             sub as_pretty_string {
114 0     0 1 0 my $self = shift;
115              
116 0         0 my $s = "SEQUENCE\n";
117 0         0 foreach $elem (@{ $self->{"SEQUENCE"} }) {
  0         0  
118 0         0 $s .= "\n" . $elem->as_pretty_string();
119             }
120 0         0 return $s;
121             }
122              
123              
124             #---------------------------------------------------------------
125             # This will return a structure usable by Convert::ASN1
126             #---------------------------------------------------------------
127             =head1
128              
129             =head2 as_asn( )
130              
131             Returns a structure usable by Convert::ASN1. Generally only called
132             from the parent's as_asn() method (or encode() method for top-level
133             message-type objects).
134              
135             =cut
136             sub as_asn {
137 8     8 1 12 my $self = shift;
138              
139             #print "Constructing array for SEQUENCE OF " . ref( $self->{"SEQUENCE"}[0] ) . "\n";
140              
141 8         14 my @a = ();
142              
143 8         8 foreach my $elem ( @{ $self->{"SEQUENCE"} }) {
  8         21  
144             #print " pushing " . ref($elem) . "\n";
145 19         68 push @a, $elem->as_asn();
146             }
147 8         30 return \@a;
148             }
149              
150             #---------------------------------------------------------------
151             #
152             #---------------------------------------------------------------
153             =head1
154              
155             =head2 add( $objref )
156              
157             Adds an element to the list.
158             Expects an object (presumably of the correct type - does no error checking!)
159              
160             =cut
161             sub add {
162 17     17 1 66 my $self = shift;
163 17         33 my ($objref) = @_;
164              
165 17         21 push @{ $self->{"SEQUENCE"} }, $objref;
  17         86  
166 17         34 return;
167             }
168              
169             #---------------------------------------------------------------
170             #
171             #---------------------------------------------------------------
172             =head1
173              
174             =head2 count()
175              
176             Returns a count of the elements in the list.
177              
178             =cut
179             sub count {
180 2     2 1 3 my $self = shift;
181              
182 2         4 return scalar( @{ $self->{"SEQUENCE"} });
  2         12  
183             }
184              
185             =head1 SEE ALSO
186              
187             See the README for system design notes.
188             See the parent class(es) for other available methods.
189             See the derived classes for examples of use.
190              
191             For more information on Interlibrary Loan standards (ISO 10160/10161),
192             a good place to start is:
193              
194             http://www.nlc-bnc.ca/iso/ill/main.htm
195              
196             =cut
197              
198             =head1 AUTHOR
199              
200             David Christensen,
201              
202             =cut
203              
204              
205             =head1 COPYRIGHT AND LICENSE
206              
207             Copyright 2003 by David Christensen
208              
209             This library is free software; you can redistribute it and/or modify it
210             under the same terms as Perl itself.
211              
212             =cut
213              
214             1;