01: /******************************************************************************
02: * Copyright (C) Lars Ivar Almli. All rights reserved. *
03: * ---------------------------------------------------------------------------*
04: * This file is part of MActor. *
05: * *
06: * MActor is free software; you can redistribute it and/or modify *
07: * it under the terms of the GNU General Public License as published by *
08: * the Free Software Foundation; either version 2 of the License, or *
09: * (at your option) any later version. *
10: * *
11: * MActor is distributed in the hope that it will be useful, *
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14: * GNU General Public License for more details. *
15: * *
16: * You should have received a copy of the GNU General Public License *
17: * along with MActor; if not, write to the Free Software *
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19: ******************************************************************************/package org.mactor.framework.commandexecutors.sql;
20:
21: import org.mactor.framework.MactorException;
22: import org.mactor.framework.TestContextImpl;
23: import org.mactor.framework.commandexecutors.ValueCommandExecutor;
24:
25: public class SqlValueCommandExecutor implements ValueCommandExecutor {
26: private String command;
27:
28: public SqlValueCommandExecutor(String command) {
29: this .command = command;
30: }
31:
32: public String extractValue(TestContextImpl context)
33: throws MactorException {
34: SqlCommandUtil sqlUtil = new SqlCommandUtil(command, context
35: .getGlobalConfig());
36: String val = null;
37: if (sqlUtil.getSqlExpression().trim().toLowerCase().endsWith(
38: ".sql"))
39: val = sqlUtil.getDb().execScriptQuery(
40: sqlUtil.getSqlExpression());
41: else
42: val = sqlUtil.getDb().execQuerySql(
43: sqlUtil.getSqlExpression());
44: return val;
45: }
46: /*
47: * private boolean same(String v1, String v2) { if (v1 == null && v2 ==
48: * null) return true; if (v1 == null) return false; return v1.equals(v2); }
49: */
50: }
|