NAME

SeeAlso::Response - SeeAlso Simple Response

DESCRIPTION

This class models a SeeAlso Simple Response which is practically the same as am OpenSearch Suggestions Response.

METHODS

new ( [ $query [, $completions, $descriptions, $urls ] )

Creates a new SeeAlso::Response object (this is the same as an OpenSearch Suggestions Response object). The optional parameters are passed to the set method, so this is equivalent:

$r = SeeAlso::Response->new($query, $completions, $descriptions, $urls);
$r = SeeAlso::Response->new->set($query, $completions, $descriptions, $urls);

set ( [ $query [, $completions, $descriptions, $urls ] )

Set the query parameter or the full content of this response. If the query parameter is an instance of SeeAlso::Identifier, the return of its normalized method is used. This methods croaks if the passed parameters do not fit to a SeeAlso response.

add ( $label [, $description [, $uri ] ] )

Add an item to the result set. All parameters must be strings. The URI is only partly checked for well-formedness, so it is recommended to use a specific URI class like URI and pass a normalized version of the URI:

$uri = URI->new( $uri_str )->canonical

Otherwise your SeeAlso response may be invalid. If you pass a non-empty URI without schema, this method will croak.

size ( )

Get the number of entries in this response.

query ( $query )

Get and/or set query parameter.

toJSON ( [ $callback ] )

Return the response in JSON format and a non-mandatory callback wrapped around. The method will croak if you supply a callback name that does not match ^[a-z][a-z0-9._\[\]]*$.

The encoding is not changed, so please only feed response objects with UTF-8 strings to get JSON in UTF-8.

toN3 ( )

Return the repsonse in RDF/N3. This method is experimental and only supports specific response types.

fromJSON ( $jsonstring )

Set this response by parsing JSON format. You can use this method as as constructor or as method;

my $response = SeeAlso::Response->fromJSON( $jsonstring );
$response->fromJSON( $jsonstring )

Croaks if the JSON string does not fit SeeAlso response format.

AUTHOR

Jakob Voss <jakob.voss@gbv.de>

LICENSE

Copyright (C) 2007-2009 by Verbundzentrale Goettingen (VZG) and Jakob Voss

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.8 or, at your option, any later version of Perl 5 you may have available.