Package org.xwiki.query
Class WrappingQuery
- java.lang.Object
-
- org.xwiki.query.WrappingQuery
-
-
Constructor Summary
Constructors Constructor Description WrappingQuery(Query wrappedQuery)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryaddFilter(QueryFilter filter)QuerybindValue(int index, Object val)Bind a positional parameter present in the statement (?index in XWQL) with a value.QueryParameterbindValue(String variable)Bind named parameter variable with a value that will be constructed using calls toQueryParameter.literal(String),QueryParameter.anychar()andQueryParameter.anyChars().QuerybindValue(String variable, Object val)Bind named parameter variable with value val in query statement.QuerybindValues(List<Object> values)Bind a list of positional parameters values.QuerybindValues(Map<String,?> values)Bind a map of named parameters values.<T> List<T>execute()List<QueryFilter>getFilters()StringgetLanguage()intgetLimit()Map<String,Object>getNamedParameters()intgetOffset()Map<Integer,Object>getPositionalParameters()StringgetStatement()StringgetWiki()QuerygetWrappedQuery()booleanisNamed()if the query is named, thenQuery.getStatement()returns a name of the query, else - a query statement.QuerysetLimit(int limit)QuerysetOffset(int offset)QuerysetWiki(String wiki)
-
-
-
Constructor Detail
-
WrappingQuery
public WrappingQuery(Query wrappedQuery)
- Parameters:
wrappedQuery- the query being wrapped
-
-
Method Detail
-
getWrappedQuery
public Query getWrappedQuery()
- Returns:
- the wrapped query
-
getStatement
public String getStatement()
- Specified by:
getStatementin interfaceQuery- Returns:
- Query statement or query name depends on
Query.isNamed()
-
getLanguage
public String getLanguage()
- Specified by:
getLanguagein interfaceQuery- Returns:
- Query language. See
Query.HQLand others.
-
isNamed
public boolean isNamed()
Description copied from interface:Queryif the query is named, thenQuery.getStatement()returns a name of the query, else - a query statement.
-
getWiki
public String getWiki()
- Specified by:
getWikiin interfaceQuery- Returns:
- virtual wiki to run the query. null is a current wiki.
- See Also:
Query.setWiki(String)
-
bindValue
public Query bindValue(String variable, Object val)
Description copied from interface:QueryBind named parameter variable with value val in query statement.
-
bindValue
public Query bindValue(int index, Object val)
Description copied from interface:QueryBind a positional parameter present in the statement (?index in XWQL) with a value. It is recommended to use named parameters if it acceptable, seeQuery.bindValue(String, Object).
-
bindValues
public Query bindValues(List<Object> values)
Description copied from interface:QueryBind a list of positional parameters values. This method is a convenience method allowing passing a list of values in one call instead of multiple calls toQuery.bindValue(int, Object).- Specified by:
bindValuesin interfaceQuery- Parameters:
values- list of positional parameters values.- Returns:
- this query
- See Also:
Query.bindValue(int, Object)
-
bindValues
public Query bindValues(Map<String,?> values)
Description copied from interface:QueryBind a map of named parameters values. This method is a convenience method allowing passing a map of values in one call instead of multiple calls toQuery.bindValue(String, Object).- Specified by:
bindValuesin interfaceQuery- Parameters:
values- list of positional parameters values.- Returns:
- this query
- See Also:
Query.bindValue(String, Object)
-
getNamedParameters
public Map<String,Object> getNamedParameters()
- Specified by:
getNamedParametersin interfaceQuery- Returns:
- map from parameter name to value.
- See Also:
Query.bindValue(String, Object)
-
bindValue
public QueryParameter bindValue(String variable)
Description copied from interface:QueryBind named parameter variable with a value that will be constructed using calls toQueryParameter.literal(String),QueryParameter.anychar()andQueryParameter.anyChars(). In order to perserve the fluent API, it's also possible to callQueryParameter.query()to get back theQuery.- Specified by:
bindValuein interfaceQuery- Parameters:
variable- the variable in the query statement (:variable).- Returns:
- an empty
QueryParameterthat needs to be populated by callingQueryParameter.literal(String),QueryParameter.anychar()andQueryParameter.anyChars()
-
getPositionalParameters
public Map<Integer,Object> getPositionalParameters()
- Specified by:
getPositionalParametersin interfaceQuery- Returns:
- list of positional parameters values.
- See Also:
Query.bindValue(int, Object)
-
addFilter
public Query addFilter(QueryFilter filter)
- Specified by:
addFilterin interfaceQuery- Parameters:
filter- theQueryFilterto add to this query- Returns:
- this query
-
getFilters
public List<QueryFilter> getFilters()
- Specified by:
getFiltersin interfaceQuery- Returns:
- the list of
QueryFilters that will be applied to this query
-
setLimit
public Query setLimit(int limit)
- Specified by:
setLimitin interfaceQuery- Parameters:
limit- seeQuery.getLimit()- Returns:
- this query
-
setOffset
public Query setOffset(int offset)
-
getLimit
public int getLimit()
- Specified by:
getLimitin interfaceQuery- Returns:
- limit the limit of result list to set (
execute().size() <= limit) - See Also:
Query.setLimit(int)
-
getOffset
public int getOffset()
- Specified by:
getOffsetin interfaceQuery- Returns:
- offset offset of query result.
- See Also:
Query.setOffset(int)
-
execute
public <T> List<T> execute() throws QueryException
- Specified by:
executein interfaceQuery- Type Parameters:
T- expected type of elements in the result list.- Returns:
- result list of the query. If several fields are selected then T=Object[].
- Throws:
QueryException- if something goes wrong.
-
-