public RunnableQuery getQueryStatement(Query query, Statement statement)
throws QueryBuilderException {
String s;
StatementParameterType paramType;
int i;
DefineStatement defineStatement;
Map<String, StatementParameter> statementParameters;
ArrayList<Object> parameters;
try {
switch (statement.getTypeAsEnum()) {
case SQL:
s = expandString(statement.getSql());
return new RunnableQuery(this.connection, query.getName(),
statement.getName(), s, null);
case STATEMENT:
defineStatement = this.manager.getDefineStatements().get(
statement.getDefine());
if (defineStatement == null)
throw new QueryBuilderException(
"Could not find defined-statement '"
+ statement.getDefine() + "'");
i = 1;
statementParameters = defineStatement.getStatementParameters();
parameters = new ArrayList<Object>();
while (true) {
s = Integer.toString(i++);
if (statementParameters.containsKey(s))
paramType = statementParameters.get(s).getTypeAsEnum();
else
break;
if (statement.getVariables().containsKey(s))
s = expandString(statement.getVariables().get(s));
else
break;
switch (paramType) {
case STRING:
parameters.add(s);
break;
case INT:
parameters.add(new Integer(s));
break;
}
}
s = expandString(defineStatement.getSql());
return new RunnableQuery(this.connection, query.getName(),
statement.getName(), s, parameters.toArray());
default: