public class BasicQueryBuilder extends Object implements QueryBuilder
| Modifier and Type | Field and Description |
|---|---|
protected URLTemplate |
template |
protected Map<String,String> |
values |
| Constructor and Description |
|---|
BasicQueryBuilder(URLTemplate template,
String startIndexDef,
String startPageDef)
Creates a new BasicQueryBuilder operating on a URL template, with default values for startIndex and startPage OpenSearch parameters
(typically provided from the URL element which encloses the URL template)
|
BasicQueryBuilder(URLTemplate template,
String countDef,
String startIndexDef,
String startPageDef)
Creates a new BasicQueryBuilder.
|
| Modifier and Type | Method and Description |
|---|---|
QueryBuilder |
clone()
Returns a copy of this query builder
|
List<String> |
getOptionalParameters()
Returns a list containing all optional parameters of the query builder
|
String |
getParameterValue(String name)
Retrieves the value assigned to a parameter of the query builder
|
String |
getQuery()
Retrieves the search query corresponding to the current state of the query builder
|
String |
getRawTemplate()
Returns the query template associated with this query builder
|
List<String> |
getRequiredParameters()
Returns a list containing all required parameters of the query builder
|
Integer |
getStartIndexDef()
Returns the default value of the StartIndex OpenSearch parameter associated with this query builder
|
Integer |
getStartPageDef()
Returns the default value of the StartPage OpenSearch parameter associated with this query builder
|
List<String> |
getUnsetParameters()
Returns a list containing all parameters to which no value has been assigned
|
boolean |
hasParameter(String name)
Determines if a parameter is contained in the parameter set of the query builder
|
boolean |
isParameterSet(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.
|
static void |
main(String[] args) |
BasicQueryBuilder |
setParameter(String name,
Integer value)
Assigns an integral value to a parameter of the query builder
|
BasicQueryBuilder |
setParameter(String name,
String value)
Assigns a string value to a parameter of the query builder
|
BasicQueryBuilder |
setParameters(List<String> names,
List<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
|
protected URLTemplate template
public BasicQueryBuilder(URLTemplate template, String startIndexDef, String startPageDef) throws Exception
template - The query template that will be used to construct queriesstartIndexDef - The default value for the startIndex standard OpenSearch parameterstartPageDef - The default value for the startPage standard OpenSearch parameterException - In case of errorpublic BasicQueryBuilder(URLTemplate template, String countDef, String startIndexDef, String startPageDef) throws Exception
BasicQueryBuilder(URLTemplate, String, String) except that it takes an additional default
value for the count standard OpenSearch parametertemplate - The query template that will be used to construct queriescountDef - The default value for the count standard OpenSearch parameterstartIndexDef - The default value for the startIndex standard OpenSearch parameterstartPageDef - The default value for the startPage standard OpenSearch parameterException - In case of errorpublic QueryBuilder clone()
QueryBuilderclone in interface QueryBuilderclone in class Objectpublic List<String> getRequiredParameters()
getRequiredParameters in interface QueryBuilderQueryBuilder.getRequiredParameters()public List<String> getOptionalParameters()
getOptionalParameters in interface QueryBuilderQueryBuilder.getOptionalParameters()public String getParameterValue(String name) throws NonExistentParameterException
getParameterValue in interface QueryBuildername - The qualified name of the parameterNonExistentParameterException - If the parameter is not contained in the parameter set of the query builderQueryBuilder.getParameterValue(String)public List<String> getUnsetParameters()
getUnsetParameters in interface QueryBuilderQueryBuilder.getUnsetParameters()public String getRawTemplate()
getRawTemplate in interface QueryBuilderQueryBuilder.getRawTemplate()public boolean hasParameter(String name)
hasParameter in interface QueryBuildername - The qualified name of the parameter to be checkedQueryBuilder.hasParameter(String)public BasicQueryBuilder setParameter(String name, String value) throws NonExistentParameterException, Exception
setParameter in interface QueryBuildername - The qualified name of the parametervalue - The value to be assigned to the parameterNonExistentParameterException - If the parameter is not contained in the parameter set of the query builderException - In case of other errorQueryBuilder.setParameter(String, String)public BasicQueryBuilder setParameter(String name, Integer value) throws NonExistentParameterException
setParameter in interface QueryBuildername - The qualified name of the parametervalue - The value to be assigned to the parameterNonExistentParameterException - If the parameter is not contained in the parameter set of the query builderQueryBuilder.setParameter(String, Integer)public BasicQueryBuilder setParameters(List<String> names, List<Object> values) throws NonExistentParameterException, Exception
setParameters in interface QueryBuildernames - A list of parameter qualified namesvalues - A list of parameter values to be assigned to the respective parameterNonExistentParameterException - If a parameter of the list is not contained in the parameter of the query builderException - In case of other errorQueryBuilder.setParameters(List, List)public boolean isParameterSet(String name)
isParameterSet in interface QueryBuildername - The qualified name of the parameterQueryBuilder.isParameterSet(String)public boolean isQueryComplete()
isQueryComplete in interface QueryBuilderQueryBuilder.isQueryComplete()public String getQuery() throws IncompleteQueryException, MalformedQueryException, Exception
getQuery in interface QueryBuilderIncompleteQueryException - If the query is not complete, i.e. there still exist unset required parametersMalformedQueryException - If the query is malformed, e.g. if a parameter value is not of the correct formException - In case of other errorQueryBuilder.getQuery()public QueryBuilder setParameters(QueryElement queryEl) throws NonExistentParameterException, Exception
setParameters in interface QueryBuilderqueryEl - The query element which will be used to assign values to the parameters of the query builderException - In case of errorNonExistentParameterExceptionQueryBuilder.setParameters(QueryElement)public Integer getStartIndexDef()
getStartIndexDef in interface QueryBuilderQueryBuilder.getStartIndexDef()public Integer getStartPageDef()
getStartPageDef in interface QueryBuilderQueryBuilder.getStartPageDef()Copyright © 2014. All Rights Reserved.