org.gcube.opensearch.opensearchlibrary.responseelements
Class OpenSearchResponse

java.lang.Object
  extended by org.gcube.opensearch.opensearchlibrary.responseelements.OpenSearchResponse
Direct Known Subclasses:
HTMLResponse, XMLResponse

public abstract class OpenSearchResponse
extends Object

Class implementing functionality common to all OpenSearch responses

Author:
gerasimos.farantatos

Field Summary
protected  boolean containsInfo
          A common OpenSearch specs violation is for a provider not to include response information in its search query responses.
protected  Boolean isFirstPage
           
protected  Boolean isLastPage
           
protected  Integer itemsPerPage
           
protected  org.slf4j.Logger logger
           
protected  Map<String,String> nsPrefixes
           
protected  Map<String,List<QueryBuilder>> queryBuilders
          An association of role values with lists of query builders
protected  List<QueryElement> queryElements
           
protected  Document response
           
protected  Integer startIndex
           
protected  Integer totalResults
           
 
Constructor Summary
OpenSearchResponse()
           
 
Method Summary
 boolean containsPagingElements()
          Determines whether this search response page contains OpenSearch response information relevant to page handling.
protected  void createQueryBuilder(Node n, QueryElementFactory qElFactory, QueryBuilder qb)
          Adds a QueryBuilder to the list of available query builders after assigning the parameter values contained in the QueryElement and another QueryBuilder
 Integer getItemsPerPage()
          Returns the number of results per page that are contained in the OpenSearch response
 List<QueryBuilder> getQueryBuilders(String role)
          Returns a list of QueryBuilder objects that may be used to construct queries for a specific role
 Document getResponse()
          Returns the OpenSearch response Document
 Integer getStartIndex()
          Returns the start index of the first result contained in the OpenSearch response
 Integer getTotalResults()
          Returns the number of total results contained in the OpenSearchResponse
 boolean isFirstPage()
          Determines whether this page is the first page of search results
 boolean isLastPage()
          Determines whether this page is the last page of search results
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

response

protected Document response

totalResults

protected Integer totalResults

startIndex

protected Integer startIndex

itemsPerPage

protected Integer itemsPerPage

isLastPage

protected Boolean isLastPage

isFirstPage

protected Boolean isFirstPage

nsPrefixes

protected Map<String,String> nsPrefixes

containsInfo

protected boolean containsInfo
A common OpenSearch specs violation is for a provider not to include response information in its search query responses. This variable should be set to false by implementations of this class if that is the case.


queryElements

protected List<QueryElement> queryElements

logger

protected org.slf4j.Logger logger

queryBuilders

protected Map<String,List<QueryBuilder>> queryBuilders
An association of role values with lists of query builders

Constructor Detail

OpenSearchResponse

public OpenSearchResponse()
Method Detail

createQueryBuilder

protected void createQueryBuilder(Node n,
                                  QueryElementFactory qElFactory,
                                  QueryBuilder qb)
                           throws Exception
Adds a QueryBuilder to the list of available query builders after assigning the parameter values contained in the QueryElement and another QueryBuilder

Parameters:
n - The Element corresponding to a query element contained in an OpenSearch response
qElFactory - The QueryElement factory to be used
qb - The QueryBuilder
Throws:
Exception

getResponse

public Document getResponse()
Returns the OpenSearch response Document

Returns:
The response

getTotalResults

public Integer getTotalResults()
Returns the number of total results contained in the OpenSearchResponse

Returns:
The number of total results

getStartIndex

public Integer getStartIndex()
Returns the start index of the first result contained in the OpenSearch response

Returns:
The start index of the first result

getItemsPerPage

public Integer getItemsPerPage()
Returns the number of results per page that are contained in the OpenSearch response

Returns:
The number of results per page

isFirstPage

public boolean isFirstPage()
Determines whether this page is the first page of search results

Returns:
true if the current page is the first page of search results

isLastPage

public boolean isLastPage()
Determines whether this page is the last page of search results

Returns:
true if the current page is the last page of search results

containsPagingElements

public boolean containsPagingElements()
Determines whether this search response page contains OpenSearch response information relevant to page handling. If not, all getter methods returning such information should return null with the possible exception of getItemsPerPage()

Returns:
true if this search response contains OpenSearch response information, false otherwise

getQueryBuilders

public List<QueryBuilder> getQueryBuilders(String role)
Returns a list of QueryBuilder objects that may be used to construct queries for a specific role

Parameters:
role - The role that t
Returns:
The list of QueryBuilders associated with the role. If no QueryBuilders corresponding to the role are found, an empty list is returned


Copyright © 2013. All Rights Reserved.