org.gcube.opensearch.opensearchlibrary.query
Class QueryBuilderDecorator

java.lang.Object
  extended by org.gcube.opensearch.opensearchlibrary.query.QueryBuilderDecorator
All Implemented Interfaces:
QueryBuilder
Direct Known Subclasses:
GeoQueryBuilder, SRUQueryBuilder, TimeQueryBuilder

public abstract class QueryBuilderDecorator
extends java.lang.Object
implements QueryBuilder


Constructor Summary
QueryBuilderDecorator(QueryBuilder qb)
           
 
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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryBuilderDecorator

public QueryBuilderDecorator(QueryBuilder qb)
Method Detail

clone

public QueryBuilder clone()
Description copied from interface: QueryBuilder
Returns a copy of this query builder

Specified by:
clone in interface QueryBuilder
Overrides:
clone in class java.lang.Object
Returns:
A new query builder whose state is the same as this instance

hasParameter

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

Specified by:
hasParameter in interface QueryBuilder
Parameters:
name - The qualified name of the parameter to be checked
Returns:
true if the parameter is present in the parameter set, false otherwise
See Also:
QueryBuilder.hasParameter(String)

getRequiredParameters

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

Specified by:
getRequiredParameters in interface QueryBuilder
Returns:
A list of all required parameters
See Also:
QueryBuilder.getRequiredParameters()

getOptionalParameters

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

Specified by:
getOptionalParameters in interface QueryBuilder
Returns:
A list of all optional parameters
See Also:
QueryBuilder.getOptionalParameters()

getUnsetParameters

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

Specified by:
getUnsetParameters in interface QueryBuilder
Returns:
A list of all unset parameters
See Also:
QueryBuilder.getUnsetParameters()

getParameterValue

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

Specified by:
getParameterValue in interface QueryBuilder
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
See Also:
QueryBuilder.getParameterValue(String)

setParameter

public 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

Specified by:
setParameter in interface QueryBuilder
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
See Also:
QueryBuilder.setParameter(String, String)

setParameter

public 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

Specified by:
setParameter in interface QueryBuilder
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
See Also:
QueryBuilder.setParameter(String, Integer)

setParameters

public 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

Specified by:
setParameters in interface QueryBuilder
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
See Also:
QueryBuilder.setParameters(List, List)

setParameters

public 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

Specified by:
setParameters in interface QueryBuilder
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
See Also:
QueryBuilder.setParameters(QueryElement)

isParameterSet

public 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.

Specified by:
isParameterSet in interface QueryBuilder
Parameters:
name - The qualified name of the parameter
Returns:
true if the value of the parameter is set, false otherwise
See Also:
QueryBuilder.isParameterSet(String)

getStartIndexDef

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

Specified by:
getStartIndexDef in interface QueryBuilder
Returns:
The default value of the StartIndex parameter
See Also:
QueryBuilder.getStartIndexDef()

getStartPageDef

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

Specified by:
getStartPageDef in interface QueryBuilder
Returns:
The default value of the StartPage parameter
See Also:
QueryBuilder.getStartPageDef()

isQueryComplete

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

Specified by:
isQueryComplete in interface QueryBuilder
Returns:
true if the query is complete, false otherwise
See Also:
QueryBuilder.isQueryComplete()

getQuery

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

Specified by:
getQuery in interface QueryBuilder
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
See Also:
QueryBuilder.getQuery()

getRawTemplate

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

Specified by:
getRawTemplate in interface QueryBuilder
Returns:
The query template
See Also:
QueryBuilder.getRawTemplate()