KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > requestmanager > ParserThread


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): ______________________________________.
23  */

24
25 package org.objectweb.cjdbc.controller.requestmanager;
26
27 import java.sql.SQLException JavaDoc;
28
29 import org.objectweb.cjdbc.common.sql.AbstractRequest;
30 import org.objectweb.cjdbc.common.sql.schema.DatabaseSchema;
31
32 /**
33  * This thread is used to process request parsing in background.
34  *
35  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet</a>
36  * @version 1.0
37  */

38 public class ParserThread extends Thread JavaDoc
39 {
40   private boolean isCaseSensitive;
41   private AbstractRequest request;
42   private DatabaseSchema dbs;
43   private int granularity;
44
45   /**
46    * Creates a new ParserThread
47    *
48    * @param request the request to parse
49    * @param dbs the database schema
50    * @param granularity the parsing granularity to use
51    * @param isCaseSensitive true if parsing is case sensitive
52    */

53   public ParserThread(
54     AbstractRequest request,
55     DatabaseSchema dbs,
56     int granularity,
57     boolean isCaseSensitive)
58   {
59     this.request = request;
60     this.dbs = dbs;
61     this.granularity = granularity;
62     this.isCaseSensitive = isCaseSensitive;
63     start();
64   }
65
66   /**
67    * @see java.lang.Runnable#run()
68    */

69   public void run()
70   {
71     try
72     {
73       if (!request.isParsed())
74         request.parse(dbs, granularity, isCaseSensitive);
75     }
76     catch (SQLException JavaDoc e)
77     {
78       System.err.println("Error while parsing request (" + e + ")");
79     }
80   }
81
82 }
83
Popular Tags