1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.query

File Query.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
86% of files have more coverage

Code metrics

0
1
1
1
180
30
1
1
1
1
1

Classes

Class Line # Actions
Query 33 1 0% 1 2
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.query;
21   
22    import java.util.List;
23    import java.util.Map;
24   
25    /**
26    * This is a Query interface, representing all queries in various languages for various stores.
27    *
28    * <p>Note that it was modeled after the JCR Query interface.</p>
29    *
30    * @version $Id: e374591a6f5d7bf42628b91e0a155029070d8e0e $
31    * @since 1.6M1
32    */
 
33    public interface Query
34    {
35    /**
36    * Indicator for Hibernate Query Language.
37    */
38    String HQL = "hql";
39   
40    /**
41    * Indicator for XPath language.
42    */
43    String XPATH = "xpath";
44   
45    /**
46    * Indicator for XWiki Query Language.
47    */
48    String XWQL = "xwql";
49   
50    /**
51    * @return Query statement or query name depends on {@link #isNamed()}
52    */
53    String getStatement();
54   
55    /**
56    * @return Query language. See {@link Query#HQL} and others.
57    */
58    String getLanguage();
59   
60    /**
61    * if the query is named, then {@link #getStatement()} returns a name of the query, else - a query statement.
62    *
63    * @return is the query named.
64    */
65    boolean isNamed();
66   
67    /**
68    * @param wiki virtual wiki to run the query. null is a current wiki.
69    * @return this query
70    */
71    Query setWiki(String wiki);
72   
73    /**
74    * @return virtual wiki to run the query. null is a current wiki.
75    * @see #setWiki(String)
76    */
77    String getWiki();
78   
79    /**
80    * Bind named parameter var with value val in query statement.
81    *
82    * @param var variable in query statement (:var).
83    * @param val value of the variable.
84    * @return this query
85    */
86    Query bindValue(String var, Object val);
87   
88    /**
89    * Bind a positional parameter present in the statement (?index in XWQL) with a value. It is recommended to use
90    * named parameters if it acceptable, see {@link #bindValue(String, Object)}.
91    *
92    * @param index index of positional parameter. Index starting number depends on the query language. According to the
93    * JPQL standard index should start from 1.
94    * @param val value of the variable.
95    * @return this query
96    */
97    Query bindValue(int index, Object val);
98   
99    /**
100    * Bind a list of positional parameters values. This method is a convenience method allowing passing a list of
101    * values in one call instead of multiple calls to {@link #bindValue(int, Object)}.
102    *
103    * @param values list of positional parameters values.
104    * @return this query
105    * @see #bindValue(int, Object)
106    */
107    Query bindValues(List<Object> values);
108   
109    /**
110    * Bind named parameter var with a value that will be constructed using calls to
111    * {@link QueryParameter#literal(String)}, {@link QueryParameter#anychar()} and {@link QueryParameter#anyChars()}.
112    * In order to perserve the fluent API, it's also possible to call {@link QueryParameter#query()} to get back the
113    * {@link Query}.
114    *
115    * @param var the variable in the query statement ({@code :var}).
116    * @return an empty {@link QueryParameter} that needs to be populated by calling
117    * {@link QueryParameter#literal(String)}, {@link QueryParameter#anychar()} and
118    * {@link QueryParameter#anyChars()}
119    * @since 8.4.5
120    * @since 9.3RC1
121    */
 
122  0 toggle default QueryParameter bindValue(String var)
123    {
124  0 throw new RuntimeException("Not implemented");
125    }
126   
127    /**
128    * @return map from parameter name to value.
129    * @see #bindValue(String, Object)
130    */
131    Map<String, Object> getNamedParameters();
132   
133    /**
134    * @return list of positional parameters values.
135    * @see #bindValue(int, Object)
136    */
137    Map<Integer, Object> getPositionalParameters();
138   
139    /**
140    * @param filter the {@link QueryFilter} to add to this query
141    * @return this query
142    */
143    Query addFilter(QueryFilter filter);
144   
145    /**
146    * @return the list of {@link QueryFilter}s that will be applied to this query
147    */
148    List<QueryFilter> getFilters();
149   
150    /**
151    * @param limit see {@link #getLimit()}
152    * @return this query
153    */
154    Query setLimit(int limit);
155   
156    /**
157    * @param offset offset of query result to set (skip first "offset" rows)
158    * @return this query
159    */
160    Query setOffset(int offset);
161   
162    /**
163    * @return limit the limit of result list to set ({@code execute().size() <= limit})
164    * @see #setLimit(int)
165    */
166    int getLimit();
167   
168    /**
169    * @return offset offset of query result.
170    * @see #setOffset(int)
171    */
172    int getOffset();
173   
174    /**
175    * @param <T> expected type of elements in the result list.
176    * @return result list of the query. If several fields are selected then T=Object[].
177    * @throws QueryException if something goes wrong.
178    */
179    <T> List<T> execute() throws QueryException;
180    }