1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.query.internal

File AbstractQueryManager.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

2
6
4
1
70
34
5
0.83
1.5
4
1.25

Classes

Class Line # Actions
AbstractQueryManager 35 6 0% 5 2
0.833333383.3%
 

Contributing tests

This file is covered by 14 tests. .

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.internal;
21   
22    import java.util.Set;
23   
24    import org.xwiki.query.Query;
25    import org.xwiki.query.QueryException;
26    import org.xwiki.query.QueryExecutorManager;
27    import org.xwiki.query.QueryManager;
28   
29    /**
30    * Base QueryManager implementation.
31    *
32    * @version $Id: a54ca2745b9405efb562efbae356dc8d397a47a2 $
33    * @since 2.0M1
34    */
 
35    public abstract class AbstractQueryManager implements QueryManager
36    {
37    /**
38    * @return the query executor manager to use. This allows extending classes to provide their version of it (for
39    * example using the Default manager or the Secure one or any other)
40    */
41    protected abstract QueryExecutorManager getQueryExecutorManager();
42   
 
43  12094 toggle @Override
44    public Set<String> getLanguages()
45    {
46  12094 return getQueryExecutorManager().getLanguages();
47    }
48   
 
49  12093 toggle @Override
50    public boolean hasLanguage(String language)
51    {
52  12093 return getLanguages().contains(language);
53    }
54   
 
55  12093 toggle @Override
56    public Query createQuery(String statement, String language) throws QueryException
57    {
58  12093 if (hasLanguage(language)) {
59  12093 return new DefaultQuery(statement, language, getQueryExecutorManager());
60    } else {
61  0 throw new QueryException("Language [" + language + "] is not supported", null, null);
62    }
63    }
64   
 
65  286 toggle @Override
66    public Query getNamedQuery(String queryName) throws QueryException
67    {
68  287 return new DefaultQuery(queryName, getQueryExecutorManager());
69    }
70    }