001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.compile.SetTransactionIsolationNode
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.compile;
023:
024: import org.apache.derby.iapi.services.context.ContextManager;
025:
026: import org.apache.derby.iapi.services.compiler.MethodBuilder;
027:
028: import org.apache.derby.iapi.error.StandardException;
029:
030: import org.apache.derby.iapi.sql.execute.ConstantAction;
031:
032: import org.apache.derby.iapi.sql.Activation;
033: import org.apache.derby.iapi.sql.ResultSet;
034:
035: import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
036:
037: import org.apache.derby.iapi.services.sanity.SanityManager;
038: import org.apache.derby.iapi.reference.ClassName;
039: import org.apache.derby.iapi.services.classfile.VMOpcode;
040:
041: /**
042: * A SetTransactionIsolationNode is the root of a QueryTree that represents a SET
043: * TRANSACTION ISOLATION command
044: *
045: * @author Jerry Brenner
046: */
047:
048: public class SetTransactionIsolationNode extends
049: TransactionStatementNode {
050: private int isolationLevel;
051:
052: /**
053: * Initializer for SetTransactionIsolationNode
054: *
055: * @param isolationLevel The new isolation level
056: */
057: public void init(Object isolationLevel) {
058: this .isolationLevel = ((Integer) isolationLevel).intValue();
059: }
060:
061: /**
062: * Convert this object to a String. See comments in QueryTreeNode.java
063: * for how this should be done for tree printing.
064: *
065: * @return This object as a String
066: */
067:
068: public String toString() {
069: if (SanityManager.DEBUG) {
070: return "isolationLevel: " + isolationLevel + "\n"
071: + super .toString();
072: } else {
073: return "";
074: }
075: }
076:
077: public String statementToString() {
078: return "SET TRANSACTION ISOLATION";
079: }
080:
081: /**
082: * generates a the code.
083: *
084: * @param acb the activation class builder for this statement
085: * @param mb The method for the method to be built
086: * @exception StandardException thrown if generation fails
087: */
088: public void generate(ActivationClassBuilder acb, MethodBuilder mb)
089: throws StandardException {
090: acb.pushGetResultSetFactoryExpression(mb);
091:
092: acb.pushThisAsActivation(mb);
093:
094: mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null,
095: "getSetTransactionResultSet", ClassName.ResultSet, 1);
096: }
097:
098: /**
099: * Create the Constant information that will drive the guts of Execution.
100: *
101: * @exception StandardException Thrown on failure
102: */
103: public ConstantAction makeConstantAction() throws StandardException {
104: return getGenericConstantActionFactory()
105: .getSetTransactionIsolationConstantAction(
106: isolationLevel);
107: }
108: }
|