org.makumba.providers
Class QueryProvider

java.lang.Object
  extended by org.makumba.providers.QueryProvider
All Implemented Interfaces:
SingletonHolder
Direct Known Subclasses:
HQLQueryProvider, MQLQueryProvider

public abstract class QueryProvider
extends Object
implements SingletonHolder

This provider makes it possible to run queries against a data source.

Version:
$Id: QueryExecutionProvider.java,v 1.1 17.09.2007 15:16:57 Manuel Exp $
Author:
Manuel Gay, Cristian Bogdan, Rudolf Mayer

Field Summary
(package private) static Map<String,QueryAnalysisProvider> analyzersByClass
           
(package private) static Map<String,QueryAnalysisProvider> analyzersByName
           
(package private) static Map<String,Class<?>> providerClasses
           
 
Constructor Summary
QueryProvider()
           
 
Method Summary
abstract  void close()
          Closes the environment, when all queries were executed
 Vector<Dictionary<String,Object>> execute(String query, Map args, int offset, int limit)
          Executes a query with a given set of parameters
protected abstract  Vector<Dictionary<String,Object>> executeRaw(String query, Map args, int offset, int limit)
           
 String getDataSource()
          Gets the data source of the QueryProvider.
protected  String getQueryAnalysisProviderClass()
           
static QueryAnalysisProvider getQueryAnalzyer(String name)
          Provides the QueryAnalysisProvider for a given query language.
protected  void init(String dataSource, Attributes a)
          Initalises the provider with the datasource
static QueryProvider makeQueryRunner(String string, String queryLang)
           
static QueryProvider makeQueryRunner(String dataSource, String name, Attributes a)
          Provides the query execution environment corresponding to the query language.
 void release()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

analyzersByClass

static final Map<String,QueryAnalysisProvider> analyzersByClass

analyzersByName

static final Map<String,QueryAnalysisProvider> analyzersByName

providerClasses

static final Map<String,Class<?>> providerClasses
Constructor Detail

QueryProvider

public QueryProvider()
Method Detail

getQueryAnalysisProviderClass

protected String getQueryAnalysisProviderClass()

getQueryAnalzyer

public static QueryAnalysisProvider getQueryAnalzyer(String name)
Provides the QueryAnalysisProvider for a given query language.

Parameters:
name - the name of the query language
Returns:
the QueryProvider able of performing analysis for this language

makeQueryRunner

public static QueryProvider makeQueryRunner(String dataSource,
                                            String name,
                                            Attributes a)
Provides the query execution environment corresponding to the query language.

Parameters:
dataSource - the source on which the query should be run
name - the name of the query execution provider (oql, hql, castorOql, ...)
Returns:

makeQueryRunner

public static QueryProvider makeQueryRunner(String string,
                                            String queryLang)

init

protected void init(String dataSource,
                    Attributes a)
Initalises the provider with the datasource

Parameters:
dataSource - the source on which the query should be run
a -

executeRaw

protected abstract Vector<Dictionary<String,Object>> executeRaw(String query,
                                                                Map args,
                                                                int offset,
                                                                int limit)

execute

public Vector<Dictionary<String,Object>> execute(String query,
                                                 Map args,
                                                 int offset,
                                                 int limit)
Executes a query with a given set of parameters

Parameters:
query - the query to execute
args - the arguments of this query
offset - from which record should results be returned
limit - until which record should results be returned
Returns:
a Vector holding Dictionaries corresponding to a result

close

public abstract void close()
Closes the environment, when all queries were executed


getDataSource

public String getDataSource()
Gets the data source of the QueryProvider.

Returns:
the data source of the provider, may be null if it just does analysis

release

public void release()
Specified by:
release in interface SingletonHolder