KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > compile > SetTransactionIsolationNode


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.SetTransactionIsolationNode
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.compile;
23
24 import org.apache.derby.iapi.services.context.ContextManager;
25
26 import org.apache.derby.iapi.services.compiler.MethodBuilder;
27
28 import org.apache.derby.iapi.error.StandardException;
29
30 import org.apache.derby.iapi.sql.execute.ConstantAction;
31
32 import org.apache.derby.iapi.sql.Activation;
33 import org.apache.derby.iapi.sql.ResultSet;
34
35 import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
36
37 import org.apache.derby.iapi.services.sanity.SanityManager;
38 import org.apache.derby.iapi.reference.ClassName;
39 import org.apache.derby.iapi.services.classfile.VMOpcode;
40
41 /**
42  * A SetTransactionIsolationNode is the root of a QueryTree that represents a SET
43  * TRANSACTION ISOLATION command
44  *
45  * @author Jerry Brenner
46  */

47
48 public class SetTransactionIsolationNode extends TransactionStatementNode
49 {
50     private int isolationLevel;
51
52     /**
53      * Initializer for SetTransactionIsolationNode
54      *
55      * @param isolationLevel The new isolation level
56      */

57     public void init(Object JavaDoc isolationLevel)
58     {
59         this.isolationLevel = ((Integer JavaDoc) isolationLevel).intValue();
60     }
61
62     /**
63      * Convert this object to a String. See comments in QueryTreeNode.java
64      * for how this should be done for tree printing.
65      *
66      * @return This object as a String
67      */

68
69     public String JavaDoc toString()
70     {
71         if (SanityManager.DEBUG)
72         {
73             return "isolationLevel: " + isolationLevel + "\n" +
74                 super.toString();
75         }
76         else
77         {
78             return "";
79         }
80     }
81
82     public String JavaDoc statementToString()
83     {
84         return "SET TRANSACTION ISOLATION";
85     }
86
87     /**
88      * generates a the code.
89      *
90      * @param acb the activation class builder for this statement
91      * @param mb The method for the method to be built
92      * @exception StandardException thrown if generation fails
93      */

94     public void generate(ActivationClassBuilder acb,
95                                 MethodBuilder mb)
96                             throws StandardException
97     {
98         acb.pushGetResultSetFactoryExpression(mb);
99
100         acb.pushThisAsActivation(mb);
101
102         mb.callMethod(VMOpcode.INVOKEINTERFACE, (String JavaDoc) null, "getSetTransactionResultSet", ClassName.ResultSet, 1);
103     }
104
105
106     /**
107      * Create the Constant information that will drive the guts of Execution.
108      *
109      * @exception StandardException Thrown on failure
110      */

111     public ConstantAction makeConstantAction() throws StandardException
112     {
113         return getGenericConstantActionFactory().getSetTransactionIsolationConstantAction(isolationLevel);
114     }
115 }
116
Popular Tags