| 1 | package Net::OAI::Record; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | =head1 NAME | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | Net::OAI::Record - An OAI-PMH record. | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Net::OAI::Record objects represent the OAI records harvested by C<GetRecord()> or C<ListRecords()> | ||||||||||||||||||||||||||||
| 15 | calls (an OAI record consists of the mandatory I<header>, an optional I<metadata> container | ||||||||||||||||||||||||||||
| 16 | element and zero or more I<about> containers) and also the reduced (I<header> only) ones | ||||||||||||||||||||||||||||
| 17 | delivered by C<ListIdentifiers()>. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | The objects are created within the processing performed by the corresponding | ||||||||||||||||||||||||||||
| 20 | L<Net::OAI::GetRecord>, L<Net:OAI::ListRecords>, and L<Net::OAI::ListIdentifiers> | ||||||||||||||||||||||||||||
| 21 | filter classes. They all sit on top of (slightly misnomed) SAX filters of class | ||||||||||||||||||||||||||||
| 22 | L<Net::OAI::Record::Header>. | ||||||||||||||||||||||||||||
| 23 | Please consult the documentation of that class if you are interested in writing | ||||||||||||||||||||||||||||
| 24 | custom handlers. | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 METHODS | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head2 new() | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | probably don't want to instantiate this yourself | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | sub new { | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my ( $class, %opts ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | return bless { | ||||||||||||||||||||||||||||
| 37 | header => $opts{ header }, | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | @{[$opts{ metadata } ? (metadata => $opts{ metadata }) : ()]}, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | @{[$opts{ recorddata } ? (recorddata => $opts{ recorddata }) : ()]}, | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 40 | }, ref( $class ) || $class; | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =head2 header() | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | Returns the C<Net::OAI::Header> object for the OAI header element that | ||||||||||||||||||||||||||||
| 46 | accompanied the record. | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =cut | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub header { | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
header: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 0 | return( $self->{ header } ); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head2 metadata() | ||||||||||||||||||||||||||||
| 56 | =head2 recorddata() | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | Returns the object (SAX Handler!) used or created by the C<metadataHandler> | ||||||||||||||||||||||||||||
| 59 | rsp. C<recordHandler> filter class at the moment the OAI::Record was created, | ||||||||||||||||||||||||||||
| 60 | namely right after parsing encounters the closing OAI record tag. | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | In the case of C<ListRecords> requests, a clone of the OAI::record is immediately | ||||||||||||||||||||||||||||
| 63 | created (by means of L<Storable>) thus on processing by the next() method these | ||||||||||||||||||||||||||||
| 64 | C<metadata()> rsp. C<recorddata()> methods will return clones of the original | ||||||||||||||||||||||||||||
| 65 | handler object taken at the moment described above. | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | Will be C<undef> when no corresponding option was provided. | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | Access to the actual data if desired has to be provided by the Handler class. | ||||||||||||||||||||||||||||
| 70 | Note that in the case of deleted records the I<record> element of the OAI-PMH response | ||||||||||||||||||||||||||||
| 71 | must not contain a metadata container and therefore the metadataHandler | ||||||||||||||||||||||||||||
| 72 | for that record will never have been active at all. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | sub metadata { | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
metadata: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | # return undef unless exists $self->{ metadata }; | ||||||||||||||||||||||||||||
| 79 | 0 | ▶ | return $self->{ metadata } || undef; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'metadata'} || undef
MC/DC0%0/1
$self->{'metadata'} || undef
$self->{'metadata'}
Truth table0%0/2
A
A= $self->{'metadata'}
| |||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub recorddata { | ||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
recorddata: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | # return undef unless exists $self->{ recorddata }; | ||||||||||||||||||||||||||||
| 86 | 0 | ▶ | return $self->{ recorddata } || undef; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'recorddata'} || undef
MC/DC0%0/1
$self->{'recorddata'} || undef
$self->{'recorddata'}
Truth table0%0/2
A
A= $self->{'recorddata'}
| |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | Ed Summers <ehs@pobox.com> | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 17 | 1; | |||||||||||||||||||||||||||