NAME

Search::Z3950::ResultSet - Z39.50 search results

SYNOPSIS

    $n = $rs->count;
    $rs->prefetch(1, $n) if $n > 0 and $n <= 20;
    foreach my $i (1..$n) {
        my $rec = $rs->record($i);
        if ($rec->isa('MARC::Record')) {
            my $title = $rec->title;
            my $author = $rec->author;
            ...
        }
        ...
    }

DESCRIPTION

Search::Z3950::ResultSet provides access to the records found in a search using Search::Z3950.

PUBLIC METHODS

new

    $rs = Search::Z3950::ResultSet->new($zrs);

Construct a new Search::Z3950::ResultSet. The single parameter is the Z39.50 result set (an instance of Net::Z3950::ResultSet).

This method should normally be called only by Search::Z3950.

count

    $n = $rs->count;

The number of matching records.

record

    $rec = $rs->record($i);

Retrieve a matching record. This will be a MARC::Record when possible (i.e., when the underlying object returned by Net::3950::ResultSet isa Net::3950::Record::USMARC); otherwise, it will be an instance of a class in the Net::3950::Record hierarchy.

The single parameter is the record number, which starts at 1 (not zero).

record throws an error if the record couldn't be fetched (e.g., if the server connection has just been lost).

NOTE: the record numbers start at 1.

Did I mention that the record numbers start at 1?

prefetch

    $rs->prefetch($i, $n);

Pre-fetch records $i to $i+$n-1 (inclusive) from the Z39.50 server. Call this method (before calling record) to reduce the number of record requests sent over the network to the server.

(If you're only interested in the first matching record, it probably makes no difference whether you call prefetch or not.)

Returns a true value if the record(s) were successfully retrieved, or a false value otherwise. The retrieved records are not returned.

(As currently implemented, this method simply invokes the present method on the Search::Z3950 object's Net::Z3950 object.)

PRIVATE METHODS

These methods are for the internal use of Search::Z3950::ResultSet (and its subclasses, if any).

zrs

    $zrs = $rs->zrs;
    $rs->zrs($zrs);

Get or set the Z39.50 result set (an instance of Net::Z3950::ResultSet).

BUGS

None that I know of. You might check http://rt.cpan.org to see if others have reported any bugs.

TO DO

  • Allow user to specify whether errors should be thrown.

  • Instead of relying on the undocumented prefetch option in Net::Z3950, use prefetch behind the scenes to speed up

  • Optionally return raw data? Probably not needed.

  • Add records method to retrieve all records at once? Probably not needed.

  • Generally, make Search::Z3950 taste less Z39.50-ish (without eliminating its expressiveness).

SEE ALSO

Search::Z3950, Net::Z3950::ResultSet, MARC::Record.

AUTHOR

Paul Hoffman <nkuitse AT cpan DOT org>

COPYRIGHT

Copyright 2003-2004 Paul M. Hoffman. All rights reserved.

This program is free software; you can redistribute it and modify it under the same terms as Perl itself.