1 /*
2 * PROJECT : DAR Runtime and Tools
3 * COPYRIGHT : Copyright (C) 1999-2004 tim.stephenson@enableit.org
4 * LICENSE : GNU LESSER GENERAL PUBLIC LICENSE
5 * Version 2.1, February 1999
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 package org.enableit.db.isql.biz;
22
23 import java.util.List;
24
25 import org.apache.log4j.Logger;
26 import org.enableit.db.beans.Provider;
27 import org.enableit.db.isql.IsqlForm;
28
29
30 /***
31 * @author tim.stephenson
32 */
33 public class IsqlModel extends Object {
34 private static Logger logger = Logger.getLogger(IsqlModel.class);
35 private String query;
36 private Provider provider;
37 private String response;
38 private List results;
39
40 public IsqlModel(Provider provider, String query) {
41 this.query = query;
42 this.provider = provider;
43 }
44
45 public IsqlModel(IsqlForm strutsForm) {
46 this.query = strutsForm.getQuery();
47 this.provider = new Provider();
48 this.provider.setJdbc2DatasourceName(strutsForm.getDataSource());
49 }
50
51 public List getResults() {
52 return results;
53 }
54
55 public void setResults(List dbResults) {
56 this.results = dbResults;
57 }
58
59 public String getResponse() {
60 return response;
61 }
62
63 public void setResponse(String msg) {
64 this.response = msg;
65 }
66
67 public String getQuery() {
68 return query;
69 }
70
71 public Provider getProvider() {
72 return provider;
73 }
74
75 /***
76 * Returns one of the enumerated statement types.
77 */
78 public int getStatementType(String sql) {
79 logger.info("METHOD_ENTRY: getStatementType");
80
81 // Test the first word to determine whether a query or update is appropriate
82 String word = sql.substring(0, sql.indexOf(" "));
83
84 logger.debug("Testing to find if a query or update: " + word);
85
86 int ret = Isql.UPDATE_STATEMENT;
87
88 if (word.equalsIgnoreCase("SELECT")) {
89 ret = Isql.QUERY_STATEMENT;
90 }
91
92 logger.info("METHOD_EXIT: getStatementType");
93
94 return ret;
95 }
96 }
This page was automatically generated by Maven