/* * Copyright 2014-2015 the original author or authors * * Licensed under the Apache License, Version 2.0 (the “License”); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an “AS IS” BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.wplatform.ddal.command; import java.util.ArrayList; import com.wplatform.ddal.command.expression.ParameterInterface; import com.wplatform.ddal.result.ResultInterface; /** * Represents a list of SQL statements. */ class CommandList extends Command { private final Command command; private final String remaining; CommandList(Parser parser, String sql, Command c, String remaining) { super(parser, sql); this.command = c; this.remaining = remaining; } @Override public ArrayList<? extends ParameterInterface> getParameters() { return command.getParameters(); } private void executeRemaining() { Command remainingCommand = session.prepareLocal(remaining); if (remainingCommand.isQuery()) { remainingCommand.query(0); } else { remainingCommand.update(); } } @Override public int update() { int updateCount = command.executeUpdate(); executeRemaining(); return updateCount; } @Override public ResultInterface query(int maxrows) { ResultInterface result = command.query(maxrows); executeRemaining(); return result; } @Override public boolean isQuery() { return command.isQuery(); } @Override public boolean isTransactional() { return true; } @Override public boolean isReadOnly() { return false; } @Override public ResultInterface queryMeta() { return command.queryMeta(); } @Override public int getCommandType() { return command.getCommandType(); } }