| SWISH-API-Remote documentation | Contained in the SWISH-API-Remote distribution. |
SWISH::API::Remote::Results - Represents the results of a search on a swished server
Stores the results of a search from a swished server. Intended to be used with SWISH::API::Remote.
returns a new SWISH::API::Remote::Results object. Normally called by SWISH::API::Remote for you.
returns zero if there were no errors reported, non-zero otherwise.
returns the string representation of the error(s) returned from the swished server.
returns the next result fetched from the swished server. If there are no more results for our query, returns undef
Arranges for the next result retrieved by NextResult to be the row with the passed number. Rows always start at 0, even when using the BEGIN option to SWISH::API::Remote::Execute().
Returns the number of total hits found for the search.
Returns the number of rows fetched for this search.
Returns a sorted name keys of the header available for the swish-e results
SWISH::API::Remote::Result, SWISH::API::Remote, swish-e
Josh Rabinowitz, <joshr@localdomain>
Copyright (C) 2004-2006 by Josh Rabinowitz
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
| SWISH-API-Remote documentation | Contained in the SWISH-API-Remote distribution. |
package SWISH::API::Remote::Results; use SWISH::API::Remote::FunctionGenerator; use strict; use warnings; ############################################ use fields qw( results hits errors debugs iterator stopwords ); ############################################ # results is a list of SWISH::API::Remote::Result objects, # hits is an int of the number of hits found by swish-e # errors is a list of lines # debugs is a list of debug lines # iterator is for NextResult() and SeekResult() sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; bless( $self, $class ); $self->{iterator} = 0; $self->{results} = []; $self->{errors} = []; $self->{hits} = 0; $self->{stopwords} = ''; #$self->{headers} = undef; return $self; } ############################################ sub Error { my $self = shift; return scalar( @{ $self->{errors} } ); } ############################################ sub ErrorString { my $self = shift; return join ( "\n", @{ $self->{errors} } ) . "\n"; } ############################################ sub SeekResult { my $self = shift; $self->{iterator} = shift || 0; } ############################################ sub NextResult { my ($self) = @_; my $ret = undef; if ( $self->{iterator} < @{ $self->{results} } ) { $ret = $self->{results}[ $self->{iterator} ]; $self->{iterator}++; } return $ret; } ############################################ sub Hits { my $self = shift; if (@_) { $self->{hits} = $_[0] } else { return ( $self->{hits} || 0 ) } } ############################################ sub Fetched { my $self = shift; exists( $self->{results} ) ? scalar( @{ $self->{results} } ) : 0; } ############################################ sub AddResult { my ( $self, $result ) = @_; push ( @{ $self->{results} }, $result ); } ############################################ sub AddError { my ( $self, $error ) = @_; push ( @{ $self->{errors} }, $error ); } ############################################ sub AddDebug { my ( $self, $debug ) = @_; push ( @{ $self->{debugs} }, $debug ); } ############################################ # for conformance with SWISH::API # TODO: Code this!!! sub HeaderNames { my $self = shift; my (%h); return sort keys %h; } ############################################ # S::A vers 0.04 syntax , according to peknet sub header_names { return HeaderNames(@_) } ############################################ SWISH::API::Remote::FunctionGenerator::makeaccessors(__PACKAGE__, qw ( results errors stopwords )); 1; __END__
1;