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 Query
addFilter(QueryFilter filter)
Query
bindValue(int index, Object val)
Bind a positional parameter present in the statement (?index in XWQL) with a value.QueryParameter
bindValue(String var)
Bind named parameter var with a value that will be constructed using calls toQueryParameter.literal(String)
,QueryParameter.anychar()
andQueryParameter.anyChars()
.Query
bindValue(String var, Object val)
Bind named parameter var with value val in query statement.Query
bindValues(List<Object> values)
Bind a list of positional parameters values.Query
bindValues(Map<String,?> values)
Bind a map of named parameters values.<T> List<T>
execute()
List<QueryFilter>
getFilters()
String
getLanguage()
int
getLimit()
Map<String,Object>
getNamedParameters()
int
getOffset()
Map<Integer,Object>
getPositionalParameters()
String
getStatement()
String
getWiki()
Query
getWrappedQuery()
boolean
isNamed()
if the query is named, thenQuery.getStatement()
returns a name of the query, else - a query statement.Query
setLimit(int limit)
Query
setOffset(int offset)
Query
setWiki(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:
getStatement
in interfaceQuery
- Returns:
- Query statement or query name depends on
Query.isNamed()
-
getLanguage
public String getLanguage()
- Specified by:
getLanguage
in interfaceQuery
- Returns:
- Query language. See
Query.HQL
and others.
-
isNamed
public boolean isNamed()
Description copied from interface:Query
if the query is named, thenQuery.getStatement()
returns a name of the query, else - a query statement.
-
getWiki
public String getWiki()
- Specified by:
getWiki
in interfaceQuery
- Returns:
- virtual wiki to run the query. null is a current wiki.
- See Also:
Query.setWiki(String)
-
bindValue
public Query bindValue(String var, Object val)
Description copied from interface:Query
Bind named parameter var with value val in query statement.
-
bindValue
public Query bindValue(int index, Object val)
Description copied from interface:Query
Bind 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:Query
Bind 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:
bindValues
in 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:Query
Bind 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:
bindValues
in 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:
getNamedParameters
in interfaceQuery
- Returns:
- map from parameter name to value.
- See Also:
Query.bindValue(String, Object)
-
bindValue
public QueryParameter bindValue(String var)
Description copied from interface:Query
Bind named parameter var 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:
bindValue
in interfaceQuery
- Parameters:
var
- the variable in the query statement (:var
).- Returns:
- an empty
QueryParameter
that needs to be populated by callingQueryParameter.literal(String)
,QueryParameter.anychar()
andQueryParameter.anyChars()
-
getPositionalParameters
public Map<Integer,Object> getPositionalParameters()
- Specified by:
getPositionalParameters
in interfaceQuery
- Returns:
- list of positional parameters values.
- See Also:
Query.bindValue(int, Object)
-
addFilter
public Query addFilter(QueryFilter filter)
- Specified by:
addFilter
in interfaceQuery
- Parameters:
filter
- theQueryFilter
to add to this query- Returns:
- this query
-
getFilters
public List<QueryFilter> getFilters()
- Specified by:
getFilters
in interfaceQuery
- Returns:
- the list of
QueryFilter
s that will be applied to this query
-
setLimit
public Query setLimit(int limit)
- Specified by:
setLimit
in interfaceQuery
- Parameters:
limit
- seeQuery.getLimit()
- Returns:
- this query
-
setOffset
public Query setOffset(int offset)
-
getLimit
public int getLimit()
- Specified by:
getLimit
in interfaceQuery
- Returns:
- limit the limit of result list to set (
execute().size() <= limit
) - See Also:
Query.setLimit(int)
-
getOffset
public int getOffset()
- Specified by:
getOffset
in interfaceQuery
- Returns:
- offset offset of query result.
- See Also:
Query.setOffset(int)
-
execute
public <T> List<T> execute() throws QueryException
- Specified by:
execute
in 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.
-
-