org.gcube.opensearch.opensearchlibrary.query
Interface QueryBuilder

All Known Implementing Classes:
BasicQueryBuilder, GeoQueryBuilder, QueryBuilderDecorator, SRUQueryBuilder, TimeQueryBuilder

public interface QueryBuilder

Interface of the query builder class that is used to construct OpenSearch queries using a query template

Author:
gerasimos.farantatos

Method Summary
 QueryBuilder clone()
          Returns a copy of this query builder
 java.util.List<java.lang.String> getOptionalParameters()
          Returns a list containing all optional parameters of the query builder
 java.lang.String getParameterValue(java.lang.String name)
          Retrieves the value assigned to a parameter of the query builder
 java.lang.String getQuery()
          Retrieves the search query corresponding to the current state of the query builder
 java.lang.String getRawTemplate()
          Returns the query template associated with this query builder
 java.util.List<java.lang.String> getRequiredParameters()
          Returns a list containing all required parameters of the query builder
 java.lang.Integer getStartIndexDef()
          Returns the default value of the StartIndex OpenSearch parameter associated with this query builder
 java.lang.Integer getStartPageDef()
          Returns the default value of the StartPage OpenSearch parameter associated with this query builder
 java.util.List<java.lang.String> getUnsetParameters()
          Returns a list containing all parameters to which no value has been assigned
 boolean hasParameter(java.lang.String name)
          Determines if a parameter is contained in the parameter set of the query builder
 boolean isParameterSet(java.lang.String name)
          Determines if a parameter has an assigned value.
 boolean isQueryComplete()
          Determines whether the query is complete and therefore ready to be issued, i.e.
 QueryBuilder setParameter(java.lang.String name, java.lang.Integer value)
          Assigns an integral value to a parameter of the query builder
 QueryBuilder setParameter(java.lang.String name, java.lang.String value)
          Assigns a string value to a parameter of the query builder
 QueryBuilder setParameters(java.util.List<java.lang.String> names, java.util.List<java.lang.Object> values)
          Assigns to each parameter contained in the list of the first argument the respective value contained in the list of the secord argument
 QueryBuilder setParameters(QueryElement queryEl)
          Sets all parameters of the query builder that are also contained in the QueryElement provided with the values contained in the QueryElement
 

Method Detail

hasParameter

boolean hasParameter(java.lang.String name)
Determines if a parameter is contained in the parameter set of the query builder

Parameters:
name - The qualified name of the parameter to be checked
Returns:
true if the parameter is present in the parameter set, false otherwise

getRequiredParameters

java.util.List<java.lang.String> getRequiredParameters()
Returns a list containing all required parameters of the query builder

Returns:
A list of all required parameters

getOptionalParameters

java.util.List<java.lang.String> getOptionalParameters()
Returns a list containing all optional parameters of the query builder

Returns:
A list of all optional parameters

getUnsetParameters

java.util.List<java.lang.String> getUnsetParameters()
Returns a list containing all parameters to which no value has been assigned

Returns:
A list of all unset parameters

getParameterValue

java.lang.String getParameterValue(java.lang.String name)
                                   throws NonExistentParameterException,
                                          java.lang.Exception
Retrieves the value assigned to a parameter of the query builder

Parameters:
name - The qualified name of the parameter
Returns:
The value of the parameter. or null if the parameter has no assigned value
Throws:
NonExistentParameterException - If the parameter is not contained in the parameter set of the query builder
java.lang.Exception - In case of other error

setParameter

QueryBuilder setParameter(java.lang.String name,
                          java.lang.String value)
                          throws NonExistentParameterException,
                                 java.lang.Exception
Assigns a string value to a parameter of the query builder

Parameters:
name - The qualified name of the parameter
value - The value to be assigned to the parameter
Returns:
The query builder with the parameter value assigned to the parameter
Throws:
NonExistentParameterException - If the parameter is not contained in the parameter set of the query builder
java.lang.Exception - In case of other error

setParameter

QueryBuilder setParameter(java.lang.String name,
                          java.lang.Integer value)
                          throws NonExistentParameterException,
                                 java.lang.Exception
Assigns an integral value to a parameter of the query builder

Parameters:
name - The qualified name of the parameter
value - The value to be assigned to the parameter
Returns:
The query builder with the parameter value assigned to the parameter
Throws:
NonExistentParameterException - If the parameter is not contained in the parameter set of the query builder
java.lang.Exception - In case of other error

setParameters

QueryBuilder setParameters(java.util.List<java.lang.String> names,
                           java.util.List<java.lang.Object> values)
                           throws NonExistentParameterException,
                                  java.lang.Exception
Assigns to each parameter contained in the list of the first argument the respective value contained in the list of the secord argument

Parameters:
names - A list of parameter qualified names
values - A list of parameter values to be assigned to the respective parameter
Returns:
The query builder with the values assigned to the parameters
Throws:
NonExistentParameterException - If a parameter of the list is not contained in the parameter of the query builder
java.lang.Exception - In case of other error

setParameters

QueryBuilder setParameters(QueryElement queryEl)
                           throws java.lang.Exception
Sets all parameters of the query builder that are also contained in the QueryElement provided with the values contained in the QueryElement

Parameters:
queryEl - The query element which will be used to assign values to the parameters of the query builder
Returns:
The query builder with the QueryElement's values assigned
Throws:
java.lang.Exception - In case of error

isParameterSet

boolean isParameterSet(java.lang.String name)
Determines if a parameter has an assigned value. More specifically, true is returned if and only if the parameter is present and its value is not equal to null and not equal to the empty string.

Parameters:
name - The qualified name of the parameter
Returns:
true if the value of the parameter is set, false otherwise

getStartIndexDef

java.lang.Integer getStartIndexDef()
Returns the default value of the StartIndex OpenSearch parameter associated with this query builder

Returns:
The default value of the StartIndex parameter

getStartPageDef

java.lang.Integer getStartPageDef()
Returns the default value of the StartPage OpenSearch parameter associated with this query builder

Returns:
The default value of the StartPage parameter

isQueryComplete

boolean isQueryComplete()
Determines whether the query is complete and therefore ready to be issued, i.e. there are no unset required parameters

Returns:
true if the query is complete, false otherwise

getQuery

java.lang.String getQuery()
                          throws IncompleteQueryException,
                                 MalformedQueryException,
                                 java.lang.Exception
Retrieves the search query corresponding to the current state of the query builder

Returns:
The search query
Throws:
IncompleteQueryException - If the query is not complete, i.e. there still exist unset required parameters
MalformedQueryException - If the query is malformed, e.g. if a parameter value is not of the correct form
java.lang.Exception - In case of other error

getRawTemplate

java.lang.String getRawTemplate()
Returns the query template associated with this query builder

Returns:
The query template

clone

QueryBuilder clone()
Returns a copy of this query builder

Returns:
A new query builder whose state is the same as this instance