// Path: src/main/java/org/deri/cqels/lang/cqels/ParserCQELS.java
// public class ParserCQELS extends SPARQLParser {
// 
//     public static final Syntax syntaxCQELS_01 = Syntax.make("http://deri.org/2011/05/query/CQELS_01");
// 
//     private interface Action {
// 
//         void exec(CQELSParser parser) throws Exception;
//     }
// 
//     @Override
//     protected Query parse$(final Query query, String queryString) {
//         query.setSyntax(syntaxCQELS_01);
// 
//         Action action = new Action() {
//             @Override
//             public void exec(CQELSParser parser) throws Exception {
//                 parser.QueryUnit();
//             }
//         };
// 
//         perform(query, queryString, action);
//         validateParsedQuery(query);
//         return query;
//     }
// 
//     public static Element parseElement(String string) {
//         final Query query = new Query();
//         Action action = new Action() {
//             @Override
//             public void exec(CQELSParser parser) throws Exception {
//                 Element el = parser.GroupGraphPattern();
//                 query.setQueryPattern(el);
//             }
//         };
//         perform(query, string, action);
//         return query.getQueryPattern();
//     }
// 
//     public static Template parseTemplate(String string) {
//         final Query query = new Query();
//         Action action = new Action() {
//             @Override
//             public void exec(CQELSParser parser) throws Exception {
//                 Template t = parser.ConstructTemplate();
//                 query.setConstructTemplate(t);
//             }
//         };
//         perform(query, string, action);
//         return query.getConstructTemplate();
//     }
// 
//     // All throwable handling.
//     private static void perform(Query query, String string, Action action) {
//         Reader in = new StringReader(string);
//         CQELSParser parser = new CQELSParser(in);
// 
//         try {
//             query.setStrict(true);
//             parser.setQuery(query);
//             action.exec(parser);
//         } catch (com.hp.hpl.jena.sparql.lang.arq.ParseException ex) {
//             throw new QueryParseException(ex.getMessage(),
//                     ex.currentToken.beginLine,
//                     ex.currentToken.beginColumn
//             );
//         } catch (com.hp.hpl.jena.sparql.lang.arq.TokenMgrError tErr) {
//             // Last valid token : not the same as token error message - but this should not happen
//             int col = parser.token.endColumn;
//             int line = parser.token.endLine;
//             throw new QueryParseException(tErr.getMessage(), line, col);
//         } catch (QueryException ex) {
//             throw ex;
//         } catch (JenaException ex) {
//             throw new QueryException(ex.getMessage(), ex);
//         } catch (Error err) {
//             // The token stream can throw errors.
//             throw new QueryParseException(err.getMessage(), err, -1, -1);
//         } catch (Throwable th) {
//             Log.warn(ParserSPARQL11.class, "Unexpected throwable: ", th);
//             throw new QueryException(th.getMessage(), th);
//         }
//     }
// }


import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.sparql.algebra.Algebra;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.core.DatasetGraph;
import com.hp.hpl.jena.sparql.engine.ExecutionContext;
import com.hp.hpl.jena.sparql.engine.QueryIterator;
import com.hp.hpl.jena.tdb.TDBFactory;
import com.hp.hpl.jena.tdb.base.file.FileFactory;
import com.hp.hpl.jena.tdb.base.file.FileSet;
import com.hp.hpl.jena.tdb.base.file.Location;
import com.hp.hpl.jena.tdb.index.IndexFactory;
import com.hp.hpl.jena.tdb.solver.OpExecutorTDB1;
import com.hp.hpl.jena.tdb.store.DatasetGraphTDB;
import com.hp.hpl.jena.tdb.store.bulkloader.BulkLoader;
import com.hp.hpl.jena.tdb.store.nodetable.NodeTable;
import com.hp.hpl.jena.tdb.store.nodetable.NodeTableNative;
import com.hp.hpl.jena.tdb.sys.SystemTDB;
import com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Properties;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.deri.cqels.lang.cqels.ParserCQELS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
     * @return cache configuration
     */
    public Properties cacheConfig() {
        return this.config;
    }

    /**
     * @param idx
     * @return router
     */
    public void router(int idx, OpRouter router) {
        this.routers.put(Integer.valueOf(idx), router);
    }

    /**
     * @param idx
     * @return router
     */
    public OpRouter router(int idx) {
        return this.routers.get(Integer.valueOf(idx));
    }

    /**
     * register a select query
     *
     * @param queryStr query string
     * @return this method return an instance of ContinuousSelect interface
     */
    public ContinuousSelect registerSelect(String queryStr) {
        Query query = new Query();
// Path: src/main/java/org/deri/cqels/lang/cqels/ParserCQELS.java
// public class ParserCQELS extends SPARQLParser {
// 
//     public static final Syntax syntaxCQELS_01 = Syntax.make("http://deri.org/2011/05/query/CQELS_01");
// 
//     private interface Action {
// 
//         void exec(CQELSParser parser) throws Exception;
//     }
// 
//     @Override
//     protected Query parse$(final Query query, String queryString) {
//         query.setSyntax(syntaxCQELS_01);
// 
//         Action action = new Action() {
//             @Override
//             public void exec(CQELSParser parser) throws Exception {
//                 parser.QueryUnit();
//             }
//         };
// 
//         perform(query, queryString, action);
//         validateParsedQuery(query);
//         return query;
//     }
// 
//     public static Element parseElement(String string) {
//         final Query query = new Query();
//         Action action = new Action() {
//             @Override
//             public void exec(CQELSParser parser) throws Exception {
//                 Element el = parser.GroupGraphPattern();
//                 query.setQueryPattern(el);
//             }
//         };
//         perform(query, string, action);
//         return query.getQueryPattern();
//     }
// 
//     public static Template parseTemplate(String string) {
//         final Query query = new Query();
//         Action action = new Action() {
//             @Override
//             public void exec(CQELSParser parser) throws Exception {
//                 Template t = parser.ConstructTemplate();
//                 query.setConstructTemplate(t);
//             }
//         };
//         perform(query, string, action);
//         return query.getConstructTemplate();
//     }
// 
//     // All throwable handling.
//     private static void perform(Query query, String string, Action action) {
//         Reader in = new StringReader(string);
//         CQELSParser parser = new CQELSParser(in);
// 
//         try {
//             query.setStrict(true);
//             parser.setQuery(query);
//             action.exec(parser);
//         } catch (com.hp.hpl.jena.sparql.lang.arq.ParseException ex) {
//             throw new QueryParseException(ex.getMessage(),
//                     ex.currentToken.beginLine,
//                     ex.currentToken.beginColumn
//             );
//         } catch (com.hp.hpl.jena.sparql.lang.arq.TokenMgrError tErr) {
//             // Last valid token : not the same as token error message - but this should not happen
//             int col = parser.token.endColumn;
//             int line = parser.token.endLine;
//             throw new QueryParseException(tErr.getMessage(), line, col);
//         } catch (QueryException ex) {
//             throw ex;
//         } catch (JenaException ex) {
//             throw new QueryException(ex.getMessage(), ex);
//         } catch (Error err) {
//             // The token stream can throw errors.
//             throw new QueryParseException(err.getMessage(), err, -1, -1);
//         } catch (Throwable th) {
//             Log.warn(ParserSPARQL11.class, "Unexpected throwable: ", th);
//             throw new QueryException(th.getMessage(), th);
//         }
//     }
// }


// Path: src/main/java/org/deri/cqels/engine/ExecContext.java
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.sparql.algebra.Algebra;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.core.DatasetGraph;
import com.hp.hpl.jena.sparql.engine.ExecutionContext;
import com.hp.hpl.jena.sparql.engine.QueryIterator;
import com.hp.hpl.jena.tdb.TDBFactory;
import com.hp.hpl.jena.tdb.base.file.FileFactory;
import com.hp.hpl.jena.tdb.base.file.FileSet;
import com.hp.hpl.jena.tdb.base.file.Location;
import com.hp.hpl.jena.tdb.index.IndexFactory;
import com.hp.hpl.jena.tdb.solver.OpExecutorTDB1;
import com.hp.hpl.jena.tdb.store.DatasetGraphTDB;
import com.hp.hpl.jena.tdb.store.bulkloader.BulkLoader;
import com.hp.hpl.jena.tdb.store.nodetable.NodeTable;
import com.hp.hpl.jena.tdb.store.nodetable.NodeTableNative;
import com.hp.hpl.jena.tdb.sys.SystemTDB;
import com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Properties;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.deri.cqels.lang.cqels.ParserCQELS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

     * @return cache configuration
     */
    public Properties cacheConfig() {
        return this.config;
    }

    /**
     * @param idx
     * @return router
     */
    public void router(int idx, OpRouter router) {
        this.routers.put(Integer.valueOf(idx), router);
    }

    /**
     * @param idx
     * @return router
     */
    public OpRouter router(int idx) {
        return this.routers.get(Integer.valueOf(idx));
    }

    /**
     * register a select query
     *
     * @param queryStr query string
     * @return this method return an instance of ContinuousSelect interface
     */
    public ContinuousSelect registerSelect(String queryStr) {
        Query query = new Query();
        ParserCQELS parser = new ParserCQELS();