File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\command\CommandList.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.command;
8
9 import java.util.ArrayList;
10 import org.h2.expression.ParameterInterface;
11 import org.h2.result.ResultInterface;
12
13 /**
14 * Represents a list of SQL statements.
15 */
16 class CommandList extends Command {
17
18 private final Command command;
19 private final String remaining;
20
21 CommandList(Parser parser, String sql, Command c, String remaining) {
22 super(parser, sql);
23 this.command = c;
24 this.remaining = remaining;
25 }
26
27 public ArrayList<? extends ParameterInterface> getParameters() {
28 return command.getParameters();
29 }
30
31 private void executeRemaining() {
32 Command remainingCommand = session.prepareLocal(remaining);
33 if (remainingCommand.isQuery()) {
34 remainingCommand.query(0);
35 } else {
36 remainingCommand.update();
37 }
38 }
39
40 public int update() {
41 int updateCount = command.executeUpdate();
42 executeRemaining();
43 return updateCount;
44 }
45
46 public ResultInterface query(int maxrows) {
47 ResultInterface result = command.query(maxrows);
48 executeRemaining();
49 return result;
50 }
51
52 public boolean isQuery() {
53 return command.isQuery();
54 }
55
56 public boolean isTransactional() {
57 return true;
58 }
59
60 public boolean isReadOnly() {
61 return false;
62 }
63
64 public ResultInterface queryMeta() {
65 return command.queryMeta();
66 }
67
68 public int getCommandType() {
69 return command.getCommandType();
70 }
71
72 }
73