org.apache.abdera.ext.opensearch.server.impl
Class AbstractOpenSearchUrlAdapter<T>

java.lang.Object
  extended by org.apache.abdera.ext.opensearch.server.impl.AbstractOpenSearchUrlAdapter<T>
Type Parameters:
T - The generic object type representing a search result.
All Implemented Interfaces:
OpenSearchUrlAdapter

public abstract class AbstractOpenSearchUrlAdapter<T>
extends Object
implements OpenSearchUrlAdapter

Abstract OpenSearchUrlAdapter providing explicit methods to implement and/or override for executing the actual search and creating the Atom feed containing search results.


Constructor Summary
AbstractOpenSearchUrlAdapter()
           
 
Method Summary
protected abstract  List<T> doSearch(RequestContext request, Map<String,String> parameters)
          Do the actual search, returning a list of search results as generic objects.
protected abstract  void fillEntry(Entry entry, T entity)
          Fill the given empty Atom entry from the given search result object.
This method is called once for every search result returned by the {#doSearch(RequestContext, Map)} method.
protected abstract  Person getOpenSearchFeedAuthor(RequestContext request)
          Get the author of the feed containing this search results.
protected abstract  String getOpenSearchFeedId(RequestContext request)
          Get the identifier of the feed containing this search results.
protected  int getOpenSearchFeedItemsPerPage(RequestContext request, Map<String,String> parameters, List<T> searchResults)
          Get the number of items (entries) contained into this page (feed).
By default, it's equal to the number of search results: override to provide a different behavior.
This element can be explicitly omitted from the feed by returning a negative value.
protected  int getOpenSearchFeedStartIndex(RequestContext request, Map<String,String> parameters, List<T> searchResults)
          Get the index number of the first result contained into this feed.
By default, this element is omitted: override to provide a different behavior.
This element can be explicitly omitted from the feed by returning a negative value.
protected abstract  String getOpenSearchFeedTitle(RequestContext request)
          Get the title of the feed containing this search results.
protected  int getOpenSearchFeedTotalResults(RequestContext request, Map<String,String> parameters, List<T> searchResults)
          Get the total number of results of this search.
By default, it's equal to the number of search results: override to provide a different behavior.
This element can be explicitly omitted from the feed by returning a negative value.
protected abstract  Date getOpenSearchFeedUpdatedDate(RequestContext request)
          Get the update date of the feed containing this search results.
protected  void postProcess(Feed feed, RequestContext request, Map<String,String> parameters, List<T> searchResults)
          Post process this feed in order to make custom modifications.
By default, this method does nothing: override to provide a different behavior.
 ResponseContext search(RequestContext request, Map<String,String> parameters)
          Make the actual search operation based on passed parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractOpenSearchUrlAdapter

public AbstractOpenSearchUrlAdapter()
Method Detail

search

public ResponseContext search(RequestContext request,
                              Map<String,String> parameters)
Description copied from interface: OpenSearchUrlAdapter
Make the actual search operation based on passed parameters.

Specified by:
search in interface OpenSearchUrlAdapter
Parameters:
request - The RequestContext object.
parameters - Search parameters extracted from the request: they are the same parameters reported into the Open Search URL template.

getOpenSearchFeedId

protected abstract String getOpenSearchFeedId(RequestContext request)
Get the identifier of the feed containing this search results.


getOpenSearchFeedTitle

protected abstract String getOpenSearchFeedTitle(RequestContext request)
Get the title of the feed containing this search results.


getOpenSearchFeedAuthor

protected abstract Person getOpenSearchFeedAuthor(RequestContext request)
Get the author of the feed containing this search results.


getOpenSearchFeedUpdatedDate

protected abstract Date getOpenSearchFeedUpdatedDate(RequestContext request)
Get the update date of the feed containing this search results.


doSearch

protected abstract List<T> doSearch(RequestContext request,
                                    Map<String,String> parameters)
Do the actual search, returning a list of search results as generic objects.


fillEntry

protected abstract void fillEntry(Entry entry,
                                  T entity)
Fill the given empty Atom entry from the given search result object.
This method is called once for every search result returned by the {#doSearch(RequestContext, Map)} method.


getOpenSearchFeedTotalResults

protected int getOpenSearchFeedTotalResults(RequestContext request,
                                            Map<String,String> parameters,
                                            List<T> searchResults)
Get the total number of results of this search.
By default, it's equal to the number of search results: override to provide a different behavior.
This element can be explicitly omitted from the feed by returning a negative value.


getOpenSearchFeedItemsPerPage

protected int getOpenSearchFeedItemsPerPage(RequestContext request,
                                            Map<String,String> parameters,
                                            List<T> searchResults)
Get the number of items (entries) contained into this page (feed).
By default, it's equal to the number of search results: override to provide a different behavior.
This element can be explicitly omitted from the feed by returning a negative value.


getOpenSearchFeedStartIndex

protected int getOpenSearchFeedStartIndex(RequestContext request,
                                          Map<String,String> parameters,
                                          List<T> searchResults)
Get the index number of the first result contained into this feed.
By default, this element is omitted: override to provide a different behavior.
This element can be explicitly omitted from the feed by returning a negative value.


postProcess

protected void postProcess(Feed feed,
                           RequestContext request,
                           Map<String,String> parameters,
                           List<T> searchResults)
Post process this feed in order to make custom modifications.
By default, this method does nothing: override to provide a different behavior.



Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.