1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.sql.GenericLanguageFactory |
4 | |
5 | Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.impl.sql; |
22 | |
23 | import org.apache.derby.iapi.services.property.PropertyFactory; |
24 | import org.apache.derby.iapi.store.access.AccessFactory; |
25 | import org.apache.derby.iapi.store.access.TransactionController; |
26 | import org.apache.derby.iapi.sql.LanguageFactory; |
27 | import org.apache.derby.iapi.sql.ParameterValueSet; |
28 | import org.apache.derby.iapi.sql.ResultDescription; |
29 | import org.apache.derby.iapi.sql.ResultColumnDescriptor; |
30 | import org.apache.derby.iapi.sql.Row; |
31 | |
32 | import org.apache.derby.iapi.services.monitor.Monitor; |
33 | import org.apache.derby.iapi.services.monitor.ModuleControl; |
34 | import org.apache.derby.iapi.error.StandardException; |
35 | |
36 | import org.apache.derby.iapi.sql.conn.LanguageConnectionFactory; |
37 | import org.apache.derby.iapi.services.loader.ClassInspector; |
38 | |
39 | import org.apache.derby.iapi.services.io.FormatIdUtil; |
40 | |
41 | import java.util.Properties; |
42 | |
43 | /** |
44 | The LanguageFactory provides system-wide services that |
45 | are available on the Database API. |
46 | |
47 | @author ames |
48 | */ |
49 | public class GenericLanguageFactory implements LanguageFactory, ModuleControl |
50 | { |
51 | |
52 | private GenericParameterValueSet emptySet; |
53 | |
54 | public GenericLanguageFactory() { } |
55 | |
56 | /* |
57 | ModuleControl interface |
58 | */ |
59 | |
60 | /** |
61 | * Start-up method for this instance of the language factory. |
62 | * This service is expected to be started and accessed relative |
63 | * to a database. |
64 | * |
65 | * @param startParams The start-up parameters (ignored in this case) |
66 | |
67 | @exception StandardException Thrown if module cannot be booted. |
68 | * |
69 | */ |
70 | public void boot(boolean create, Properties startParams) throws StandardException |
71 | { |
72 | LanguageConnectionFactory lcf = (LanguageConnectionFactory) Monitor.findServiceModule(this, LanguageConnectionFactory.MODULE); |
73 | PropertyFactory pf = lcf.getPropertyFactory(); |
74 | if (pf != null) |
75 | pf.addPropertySetNotification(new LanguageDbPropertySetter()); |
76 | |
77 | emptySet = new GenericParameterValueSet(null, 0, false); |
78 | } |
79 | |
80 | /** |
81 | * Stop this module. In this case, nothing needs to be done. |
82 | */ |
83 | |
84 | public void stop() { |
85 | } |
86 | |
87 | /* LanguageFactory methods */ |
88 | |
89 | /** |
90 | * Factory method for getting a ParameterValueSet |
91 | * |
92 | * @see LanguageFactory#newParameterValueSet |
93 | */ |
94 | public ParameterValueSet newParameterValueSet(ClassInspector ci, int numParms, boolean hasReturnParam) |
95 | { |
96 | if (numParms == 0) |
97 | return emptySet; |
98 | |
99 | return new GenericParameterValueSet(ci, numParms, hasReturnParam); |
100 | } |
101 | |
102 | /** |
103 | * Get a new result description from the input result |
104 | * description. Picks only the columns in the column |
105 | * array from the inputResultDescription. |
106 | * |
107 | * @param inputResultDescription the input rd |
108 | * @param theCols array of ints, non null |
109 | * |
110 | * @return ResultDescription the rd |
111 | */ |
112 | public ResultDescription getResultDescription |
113 | ( |
114 | ResultDescription inputResultDescription, |
115 | int[] theCols |
116 | ) |
117 | { |
118 | return new GenericResultDescription(inputResultDescription, theCols); |
119 | } |
120 | |
121 | /** |
122 | * Get a new result description |
123 | * |
124 | * @param cols an array of col descriptors |
125 | * @param type the statement type |
126 | * |
127 | * @return ResultDescription the rd |
128 | */ |
129 | public ResultDescription getResultDescription |
130 | ( |
131 | ResultColumnDescriptor[] cols, |
132 | String type |
133 | ) |
134 | { |
135 | return new GenericResultDescription(cols, type); |
136 | } |
137 | |
138 | /* |
139 | ** REMIND: we will need a row and column factory |
140 | ** when we make putResultSets available for users' |
141 | ** server-side JDBC methods. |
142 | */ |
143 | } |