org.gcube.opensearch.opensearchlibrary.queryelements
Class BasicQueryElement

java.lang.Object
  extended by org.gcube.opensearch.opensearchlibrary.queryelements.BasicQueryElement
All Implemented Interfaces:
QueryElement

public class BasicQueryElement
extends java.lang.Object
implements QueryElement

Query element class implementing the QueryElement interface, which provides standard OpenSearch query element functionality

Author:
gerasimos.farantatos

Constructor Summary
BasicQueryElement(org.w3c.dom.Element query)
          Creates a new instance
 
Method Summary
 boolean describesExampleQuery()
          Determines whethe the query element describes an example query
 java.lang.String getCount()
          Returns the value of the count OpenSearch parameter contained in the query element
 java.lang.String getInputEncoding()
          Returns the value of the inputEncoding OpenSearch parameter contained in the query element
 java.lang.String getLanguage()
          Returns the value of the language OpenSearch parameter contained in the query element
 java.lang.String getOutputEncoding()
          Returns the value of the outputEncoding OpenSearch parameter contained in the query element
 java.util.Map<java.lang.String,java.lang.String> getQueryParameters()
          Returns all parameters contained in the query element along with their corresponding values
 java.lang.String getRole()
          Returns the role of the search request described in the query element
 java.lang.String getSearchTerms()
          Returns the value of the searchTerms OpenSearch parameter contained in the query element
 java.lang.String getStartIndex()
          Returns the value of the startIndex OpenSearch parameter contained in the query element
 java.lang.String getStartPage()
          Returns the value of the startPage OpenSearch parameter contained in the query element
 java.lang.String getTitle()
          Returns a description describing the search request described in the query element
 java.lang.String getTotalResults()
          Returns the expected number of results that will be returned if the search request contained in the query element were made
 boolean isRoleSupported()
          Determines whether the query element supports the query role provided
 void parse()
          Processes a query element
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicQueryElement

public BasicQueryElement(org.w3c.dom.Element query)
Creates a new instance

Parameters:
query - A DOM element that will be processed in order to create a BasicQueryElement instance
Method Detail

parse

public void parse()
           throws java.lang.Exception
Processes a query element

Specified by:
parse in interface QueryElement
Throws:
java.lang.Exception - If the query element is not valid according to the OpenSearch specification or in case of other error
See Also:
QueryElement.parse()

getRole

public java.lang.String getRole()
                         throws java.lang.Exception
Returns the role of the search request described in the query element

Specified by:
getRole in interface QueryElement
Returns:
The role of the search request
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getRole()

isRoleSupported

public boolean isRoleSupported()
                        throws java.lang.Exception
Determines whether the query element supports the query role provided

Specified by:
isRoleSupported in interface QueryElement
Returns:
true if the query element supports the role provided, false otherwise
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.isRoleSupported()

getTitle

public java.lang.String getTitle()
                          throws java.lang.Exception
Returns a description describing the search request described in the query element

Specified by:
getTitle in interface QueryElement
Returns:
A description of the search request
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getTitle()

getTotalResults

public java.lang.String getTotalResults()
                                 throws java.lang.Exception
Returns the expected number of results that will be returned if the search request contained in the query element were made

Specified by:
getTotalResults in interface QueryElement
Returns:
The expected number of results
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getTotalResults()

getSearchTerms

public java.lang.String getSearchTerms()
                                throws java.lang.Exception
Returns the value of the searchTerms OpenSearch parameter contained in the query element

Specified by:
getSearchTerms in interface QueryElement
Returns:
The value of the searchTerms parameter
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getSearchTerms()

getCount

public java.lang.String getCount()
                          throws java.lang.Exception
Returns the value of the count OpenSearch parameter contained in the query element

Specified by:
getCount in interface QueryElement
Returns:
The value of the count parameter
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getCount()

getStartIndex

public java.lang.String getStartIndex()
                               throws java.lang.Exception
Returns the value of the startIndex OpenSearch parameter contained in the query element

Specified by:
getStartIndex in interface QueryElement
Returns:
The value of the startIndex parameter
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getStartIndex()

getStartPage

public java.lang.String getStartPage()
                              throws java.lang.Exception
Returns the value of the startPage OpenSearch parameter contained in the query element

Specified by:
getStartPage in interface QueryElement
Returns:
The value of the startPage parameter
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getStartPage()

getLanguage

public java.lang.String getLanguage()
                             throws java.lang.Exception
Returns the value of the language OpenSearch parameter contained in the query element

Specified by:
getLanguage in interface QueryElement
Returns:
The value of the language parameter
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getLanguage()

getInputEncoding

public java.lang.String getInputEncoding()
                                  throws java.lang.Exception
Returns the value of the inputEncoding OpenSearch parameter contained in the query element

Specified by:
getInputEncoding in interface QueryElement
Returns:
The value of the inputEncoding parameter
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getInputEncoding()

getOutputEncoding

public java.lang.String getOutputEncoding()
                                   throws java.lang.Exception
Returns the value of the outputEncoding OpenSearch parameter contained in the query element

Specified by:
getOutputEncoding in interface QueryElement
Returns:
The value of the outputEncoding parameter
Throws:
java.lang.Exception - If the query element is not initialized or in case of other error
See Also:
QueryElement.getOutputEncoding()

describesExampleQuery

public boolean describesExampleQuery()
Determines whethe the query element describes an example query

Specified by:
describesExampleQuery in interface QueryElement
Returns:
true if the query element describes an example query, false otherwise
See Also:
QueryElement.describesExampleQuery()

getQueryParameters

public java.util.Map<java.lang.String,java.lang.String> getQueryParameters()
                                                                    throws java.lang.Exception
Returns all parameters contained in the query element along with their corresponding values

Specified by:
getQueryParameters in interface QueryElement
Returns:
All parameters-value pairs contained in the query element
Throws:
java.lang.Exception - In case of error
See Also:
QueryElement.getQueryParameters()