KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.GrantNode
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.sql.execute.ConstantAction;
25 import org.apache.derby.impl.sql.execute.PrivilegeInfo;
26 import org.apache.derby.iapi.services.sanity.SanityManager;
27 import org.apache.derby.iapi.error.StandardException;
28
29 import java.util.HashMap JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32
33 /**
34  * This class represents a GRANT statement.
35  */

36 public class GrantNode extends DDLStatementNode
37 {
38     private PrivilegeNode privileges;
39     private List JavaDoc grantees;
40
41     /**
42      * Convert this object to a String. See comments in QueryTreeNode.java
43      * for how this should be done for tree printing.
44      *
45      * @return This object as a String
46      */

47
48     public String JavaDoc toString()
49     {
50         if (SanityManager.DEBUG)
51         {
52             StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
53             for( Iterator JavaDoc it = grantees.iterator(); it.hasNext();)
54             {
55                 if( sb.length() > 0)
56                     sb.append( ",");
57                 sb.append( it.next().toString());
58             }
59             return super.toString() +
60                    privileges.toString() +
61                    "TO: \n" + sb.toString() + "\n";
62         }
63         else
64         {
65             return "";
66         }
67     } // end of toString
68

69     public String JavaDoc statementToString()
70     {
71         return "GRANT";
72     }
73
74     
75     /**
76      * Initialize a GrantNode.
77      *
78      * @param privileges PrivilegesNode
79      * @param grantees List
80      */

81     public void init( Object JavaDoc privileges,
82                       Object JavaDoc grantees)
83     {
84         this.privileges = (PrivilegeNode) privileges;
85         this.grantees = (List JavaDoc) grantees;
86     }
87
88     /**
89      * Bind this GrantNode. Resolve all table, column, and routine references.
90      *
91      * @return the bound GrantNode
92      *
93      * @exception StandardException Standard error policy.
94      */

95     public QueryTreeNode bind() throws StandardException
96     {
97         privileges = (PrivilegeNode) privileges.bind( new HashMap JavaDoc(), grantees, true);
98         return this;
99     } // end of bind
100

101
102     /**
103      * Create the Constant information that will drive the guts of Execution.
104      *
105      * @exception StandardException Standard error policy.
106      */

107     public ConstantAction makeConstantAction() throws StandardException
108     {
109         return getGenericConstantActionFactory().getGrantConstantAction( privileges.makePrivilegeInfo(),
110                                                                          grantees);
111     }
112 }
113
Popular Tags