| 1 | package Net::OAI::ResumptionToken; | ||||||||||||||||||||
| 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 | 17 | ▶ | use base qw( XML::SAX::Base ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 17 | ▶ | use Carp qw( carp ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | Net::OAI::ResumptionToken - An OAI-PMH resumption token. | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | This SAX filter records resumption token elements. | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | =head1 METHODS | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | =head2 new() | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | sub new { | ||||||||||||||||||||
| 26 | 1 | ▶ | my ( $class, %opts ) = @_; | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 27 | 1 | ▶ | my $self = bless \%opts, ref( $class ) || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 28 | 1 | $self->{ _insideResumptionToken } = 0; | |||||||||||||||||||
| 29 | 1 | $self->{ token } = $self->{ expirationDate } = $self->{ completeListSize } = $self->{ cursor } = undef; | |||||||||||||||||||
| 30 | 1 | return( $self ); | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | =head2 token() | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | (Sets and) returns the contents of the resumptionToken element. | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | All methods return C<undef> if no token was encountered. | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | =cut | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | sub token { | ||||||||||||||||||||
| 42 | 0 | ▶ | my ( $self, $token ) = @_; | ||||||||||||||||||
|
Subroutine
token: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 43 | 0 | ▶ | if ( $token ) { $self->{ token } = $token; } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 0 | return( $self->{ resumptionTokenText } ); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | =head2 expirationDate() | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =cut | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | sub expirationDate { | ||||||||||||||||||||
| 52 | 2 | ▶ | my ( $self, $date ) = @_; | ||||||||||||||||||
|
Subroutine
expirationDate: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 53 | 2 | ▶ | if ( $date ) { $self->{ expirationDate } = $date; } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 2 | return( $self->{ expirationDate } ); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | =head2 completeListSize() | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | =cut | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | sub completeListSize { | ||||||||||||||||||||
| 62 | 2 | ▶ | my ( $self, $size ) = @_; | ||||||||||||||||||
|
Subroutine
completeListSize: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 63 | 2 | ▶ | if ( $size ) { $self->{ completeListSize } = $size; } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | 2 | return( $self->{ completeListSize } ); | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =head2 cursor() | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | sub cursor { | ||||||||||||||||||||
| 72 | 2 | ▶ | my ( $self, $cursor ) = @_; | ||||||||||||||||||
|
Subroutine
cursor: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 73 | 2 | ▶ | if ( $cursor ) { $self->{ cursor } = $cursor; } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | 2 | return( $self->{ cursor } ); | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | =head1 AUTHORS | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | Ed Summers <ehs@pobox.com> | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | ## internal stuff | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | ## all children of Net::OAI::Base should call this to make sure | ||||||||||||||||||||
| 87 | ## certain object properties are set | ||||||||||||||||||||
| 88 | sub start_prefix_mapping { | ||||||||||||||||||||
| 89 | 0 | ▶ | my ($self, $mapping) = @_; | ||||||||||||||||||
|
Subroutine
start_prefix_mapping: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 90 | 0 | ▶ | die "rT: self not defined" unless defined $self; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 91 | 0 | ▶ | return $self->SUPER::start_prefix_mapping( $mapping ) if $self->get_handler(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 92 | 0 | die "rT: start_prefix_mapping @{[$mapping]} w/o Handler"; | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | sub start_element { | ||||||||||||||||||||
| 97 | 0 | ▶ | my ( $self, $element ) = @_; | ||||||||||||||||||
|
Subroutine
start_element: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||
| 98 | 0 | ▶ | return $self->SUPER::start_element( $element ) unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 0 | ▶ | if ( $element->{ LocalName } eq 'resumptionToken' ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 101 | 0 | my $attr = $element->{ Attributes }; | |||||||||||||||||||
| 102 | 0 | ▶ | $self->{ expirationDate } = $attr->{ '{}expirationDate' }{ Value } if $attr->{ '{}expirationDate' }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 103 | 0 | ▶ | $self->{ completeListSize } = $attr->{ '{}completeListSize' }{ Value } if $attr->{ '{}completeListSize' }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 104 | 0 | ▶ | $self->{ cursor } = $attr->{ '{}cursor' }{ Value } if $attr->{ '{}cursor' }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 105 | 0 | $self->{ resumptionTokenText } = ""; | |||||||||||||||||||
| 106 | 0 | $self->{ _insideResumptionToken } = 1; | |||||||||||||||||||
| 107 | } elsif ( $self->{ _insideResumptionToken } ) { | ||||||||||||||||||||
| 108 | 0 | carp "start of unhandled subelement ".$element->{ Name }." within resumptionToken"; | |||||||||||||||||||
| 109 | } else { | ||||||||||||||||||||
| 110 | 0 | $self->SUPER::start_element( $element ); | |||||||||||||||||||
| 111 | } | ||||||||||||||||||||
| 112 | } | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | sub end_element { | ||||||||||||||||||||
| 115 | 0 | ▶ | my ( $self, $element ) = @_; | ||||||||||||||||||
|
Subroutine
end_element: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 116 | 0 | ▶ | return $self->SUPER::end_element( $element ) unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | 0 | ▶ | if ( $element->{ LocalName } eq 'resumptionToken' ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 119 | 0 | Net::OAI::Harvester::debug( "caught resumption token" ); | |||||||||||||||||||
| 120 | 0 | $self->{ _insideResumptionToken } = 0; | |||||||||||||||||||
| 121 | } elsif ( $self->{ _insideResumptionToken } ) { | ||||||||||||||||||||
| 122 | 0 | carp "end of unhandled subelement ".$element->{ Name }." within resumptionToken"; | |||||||||||||||||||
| 123 | } else { | ||||||||||||||||||||
| 124 | 0 | $self->SUPER::end_element( $element ); | |||||||||||||||||||
| 125 | } | ||||||||||||||||||||
| 126 | } | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | sub characters { | ||||||||||||||||||||
| 129 | 0 | ▶ | my ( $self, $characters ) = @_; | ||||||||||||||||||
|
Subroutine
characters: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | 0 | ▶ | if ( $self->{ _insideResumptionToken } ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 132 | 0 | $self->{ resumptionTokenText } .= $characters->{ Data }; | |||||||||||||||||||
| 133 | } else { | ||||||||||||||||||||
| 134 | 0 | $self->SUPER::characters( $characters ); | |||||||||||||||||||
| 135 | } | ||||||||||||||||||||
| 136 | } | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | 17 | 1; | |||||||||||||||||||
| 139 | |||||||||||||||||||||