| Keystone-Resolver documentation | Contained in the Keystone-Resolver distribution. |
Keystone::Resolver::Result - a result, with its type, resolved from an OpenURL
$result = new OpenURL::Result("fulltext", "", "CQL Tutorial", 15,
"http://zing.z3950.org/cql/intro.html");
$type = $result->type();
$text = $result->text()
A Keystone::Resolver::Result object represents one of the
(potentially) many results found by resolving an OpenURL. It can't do
anything useful apart from tell you the data with which it was
created, and render itself. What we're looking for here is, I think,
what we doctors, in fact, call a struct.
$r1 = new OpenURL::Result("fulltext", "", "CQL web site", 10,
"http://zing/z3950.org/cql/");
$r2 = new OpenURL::Result("bookstore", "", "Amazon", 25,
"isbn:0253333490");
$r3 = new OpenURL::Result("citation", "JVP", "JVP format citation", 99,
"Wedel 2003. <i>Paleobiology</i>.",
"text/html", 1);
Creates a new Keystone::Resolver::Result object with the specified parameters. A result is represented by the following components:
A short string indicating the type of service that provided the
result, e.g. fulltext, abstract, websearch, citation.
These are intended to be recognised by XSLT stylesheets rather than
read by humans.
A short string indicating the particular service that provided the
result. This, too, is intended for stylesheets to compare with rather
than for humans: service is the human-readable equivalent. This
tag is useful for some types of service (e.g. citation) but not
necessarily for others (e.g. fulltext).
A short human-readable description of the service that provided the result.
An integer representing the priority of this result relative to others of the same type. Lower values represent higher priorities.
The text of the result itself. Its form may vary depending on the
type of service that provided it. For example, for fulltext and
abstract services, it's a URI; but for citation services, it's
an HTML fragment.
The text of the result itself. Its form may vary depending on the
type of service that provided it. For example, for fulltext and
abstract services, it's a URI; but for citation services, it's
an HTML fragment.
(Optional) An indication of the MIME-type of the text.
(Optional) If provided and true, then this result is the only one explicitly requested by the ContextObject.
$type = $result->type(); $text = $result->text(); die if $type ne "fulltext" || $text ne "http://zing.z3950.org/cql/";
type() returns the type of a Keystone::Resolver::Result,
tag() returns a tag for the name of the service that provides it,
service() returns a description of the service, priority()
returns its priority, text() returns its text, mimeType()
returns its mime-type and single() returns an indication of whether
the result was the only one requested. These are, respectively, the
first to seventh parameters with which it was created.
print $result->render(), "\n";
Returns a human-readable string representing a
Keystone::Resolver::Result.
| Keystone-Resolver documentation | Contained in the Keystone-Resolver distribution. |
# $Id: Result.pm,v 1.3 2008-04-25 17:45:52 mike Exp $ package Keystone::Resolver::Result; use strict; use warnings;
sub new { my $class = shift(); my($type, $tag, $service, $priority, $text, $mimeType, $single) = @_; return bless { type => $type, tag => $tag, service => $service, priority => $priority, text => $text, mimeType => $mimeType, single => $single, }, $class; }
sub type { return shift()->{type} } sub tag { return shift()->{tag} } sub service { return shift()->{service} } sub priority { return shift()->{priority} } sub text { return shift()->{text} } sub mimeType { return shift()->{mimeType} } sub single { return shift()->{single} }
sub render() { my $this = shift(); my $type = $this->type(); my $tag = $this->tag(); my $service = $this->service(); my $priority = $this->priority(); my $text = $this->text(); return ("$type: " . (defined $tag ? "$tag" : "") . (defined $service ? "=$service" : "") . (defined $priority ? " (priority $priority)" : "") . " - $text"); } 1;