File Coverage

blib/lib/Biblio/ILL/ISO/Extension.pm
Criterion Covered Total %
statement 7 43 16.2
branch 0 22 0.0
condition 0 3 0.0
subroutine 3 7 42.8
pod 0 4 0.0
total 10 79 12.6


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::Extension;
2              
3 4     4   626 use Biblio::ILL::ISO::ILLASNtype;
  4         8  
  4         126  
4              
5 4     4   22 use Carp;
  4         9  
  4         299  
6              
7             our $VERSION = '0.01';
8             #---------------------------------------------------------------------------
9             # Mods
10             # 0.01 - 2003.08.11 - original version
11             #---------------------------------------------------------------------------
12              
13 4     4   2006 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
14              
15             # From the ASN
16             #
17             #Extension ::= SEQUENCE {
18             # --identifier [0] IMPLICIT INTEGER,
19             # identifier [0] OBJECT IDENTIFIER,
20             # critical [1] IMPLICIT BOOLEAN, -- DEFAULT FALSE,
21             # item [2] ANY DEFINED BY identifier
22             # --item [2] APDU-Delivery-Info
23             # }
24             #
25             #
26              
27             #---------------------------------------------------------------
28             #
29             #---------------------------------------------------------------
30             sub new {
31 0     0 0   my $class = shift;
32 0           my $self = {};
33              
34 0 0         if (@_) {
35 0           my ($identifier, $critical, $item) = @_;
36              
37 0 0         croak "missing identifier" unless ($identifier);
38 0 0         croak "missing critical" unless ($critical);
39 0 0         croak "missing item" unless ($item);
40              
41 0           $self->{"identifier"} = $identifier;
42 0           $self->{"critical"} = $critical;
43 0           $self->{"item"} = $item;
44             }
45              
46 0   0       bless($self, ref($class) || $class);
47 0           return ($self);
48             }
49              
50              
51             #---------------------------------------------------------------
52             #
53             #---------------------------------------------------------------
54             sub set {
55 0     0 0   my $self = shift;
56 0           my ($identifier, $critical, $item) = @_;
57            
58 0 0         croak "missing identifier" unless ($identifier);
59 0 0         croak "missing critical" unless ($critical);
60 0 0         croak "missing item" unless ($item);
61            
62 0           $self->{"identifier"} = $identifier;
63 0           $self->{"critical"} = $critical;
64 0           $self->{"item"} = $item;
65              
66 0           return;
67             }
68              
69             #---------------------------------------------------------------
70             #
71             #---------------------------------------------------------------
72             sub from_asn {
73 0     0 0   my $self = shift;
74 0           my $href = shift;
75              
76 0           foreach my $k (keys %$href) {
77             #print ref($self) . "...$k\n";
78              
79 0 0         if ($k =~ /^identifier$/) {
    0          
    0          
80 0           $self->{$k} = $href->{$k};
81              
82             } elsif ($k =~ /^critical$/) {
83 0           $self->{$k} = $href->{$k};
84              
85             } elsif ($k =~ /^item$/) {
86 0 0         croak "need identifier!" unless ($self->{identifier});
87 0           $self->{$k} = SelectExtensionType($self->{identifier});
88              
89             } else {
90 0           croak "invalid " . ref($self) . " element: [$k]";
91             }
92              
93             }
94 0           return $self;
95             }
96              
97             #---------------------------------------------------------------
98             #
99             #---------------------------------------------------------------
100             sub SelectExtensionType {
101 0     0 0   my $id = shift;
102              
103 0           print "+----------------------\n";
104 0           print "| id: $id\n";
105 0           print "+----------------------\n";
106              
107             # depending on the $id, create the appropriate type
108             # and return it.
109              
110 0           return 1;
111             }
112              
113              
114             1;