KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.CreateSchemaNode
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
27 import org.apache.derby.iapi.sql.ResultSet;
28 import org.apache.derby.iapi.sql.execute.ConstantAction;
29
30 import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext;
31 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
32 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
33 import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator;
34
35 import org.apache.derby.iapi.sql.compile.CompilerContext;
36 import org.apache.derby.iapi.sql.conn.Authorizer;
37
38 import org.apache.derby.iapi.error.StandardException;
39
40 import org.apache.derby.iapi.services.monitor.Monitor;
41 import org.apache.derby.iapi.services.sanity.SanityManager;
42
43 import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
44 import org.apache.derby.impl.sql.execute.BaseActivation;
45
46 import java.util.Properties JavaDoc;
47
48 /**
49  * A CreateSchemaNode is the root of a QueryTree that
50  * represents a CREATE SCHEMA statement.
51  *
52  * @author jamie
53  */

54
55 public class CreateSchemaNode extends DDLStatementNode
56 {
57     private String JavaDoc name;
58     private String JavaDoc aid;
59     
60     /**
61      * Initializer for a CreateSchemaNode
62      *
63      * @param schemaName The name of the new schema
64      * @param aid The authorization id
65      *
66      * @exception StandardException Thrown on error
67      */

68     public void init(
69             Object JavaDoc schemaName,
70             Object JavaDoc aid)
71         throws StandardException
72     {
73         /*
74         ** DDLStatementNode expects tables, null out
75         ** objectName explicitly to clarify that we
76         ** can't hang with schema.object specifiers.
77         */

78         initAndCheck(null);
79     
80         this.name = (String JavaDoc) schemaName;
81         this.aid = (String JavaDoc) aid;
82     }
83
84     /**
85      * Convert this object to a String. See comments in QueryTreeNode.java
86      * for how this should be done for tree printing.
87      *
88      * @return This object as a String
89      */

90
91     public String JavaDoc toString()
92     {
93         if (SanityManager.DEBUG)
94         {
95             return super.toString() +
96                 "schemaName: " + "\n" + name + "\n" +
97                 "authorizationId: " + "\n" + aid + "\n";
98         }
99         else
100         {
101             return "";
102         }
103     }
104
105     /**
106      * Bind this createSchemaNode. Main work is to create a StatementPermission
107      * object to require CREATE_SCHEMA_PRIV at execution time.
108      */

109     public QueryTreeNode bind() throws StandardException
110     {
111         super.bind();
112
113         CompilerContext cc = getCompilerContext();
114         if (isPrivilegeCollectionRequired())
115             cc.addRequiredSchemaPriv(name, aid, Authorizer.CREATE_SCHEMA_PRIV);
116
117         return this;
118     }
119     
120     public String JavaDoc statementToString()
121     {
122         return "CREATE SCHEMA";
123     }
124
125     // We inherit the generate() method from DDLStatementNode.
126

127     /**
128      * Create the Constant information that will drive the guts of Execution.
129      *
130      * @exception StandardException Thrown on failure
131      */

132     public ConstantAction makeConstantAction()
133     {
134         return getGenericConstantActionFactory().getCreateSchemaConstantAction(name, aid);
135     }
136 }
137
Popular Tags