KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > GenericLanguageFactory


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.GenericLanguageFactory
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;
23
24 import org.apache.derby.iapi.services.property.PropertyFactory;
25 import org.apache.derby.iapi.store.access.AccessFactory;
26 import org.apache.derby.iapi.store.access.TransactionController;
27 import org.apache.derby.iapi.sql.LanguageFactory;
28 import org.apache.derby.iapi.sql.ParameterValueSet;
29 import org.apache.derby.iapi.sql.ResultDescription;
30 import org.apache.derby.iapi.sql.ResultColumnDescriptor;
31 import org.apache.derby.iapi.sql.Row;
32
33 import org.apache.derby.iapi.services.monitor.Monitor;
34 import org.apache.derby.iapi.services.monitor.ModuleControl;
35 import org.apache.derby.iapi.error.StandardException;
36
37 import org.apache.derby.iapi.sql.conn.LanguageConnectionFactory;
38 import org.apache.derby.iapi.services.loader.ClassInspector;
39
40 import org.apache.derby.iapi.services.io.FormatIdUtil;
41
42 import java.util.Properties JavaDoc;
43
44 /**
45     The LanguageFactory provides system-wide services that
46     are available on the Database API.
47
48     @author ames
49  */

50 public class GenericLanguageFactory implements LanguageFactory, ModuleControl
51 {
52
53     private GenericParameterValueSet emptySet;
54
55     public GenericLanguageFactory() { }
56
57     /*
58         ModuleControl interface
59      */

60
61     /**
62      * Start-up method for this instance of the language factory.
63      * This service is expected to be started and accessed relative
64      * to a database.
65      *
66      * @param startParams The start-up parameters (ignored in this case)
67
68        @exception StandardException Thrown if module cannot be booted.
69      *
70      */

71     public void boot(boolean create, Properties JavaDoc startParams) throws StandardException
72     {
73         LanguageConnectionFactory lcf = (LanguageConnectionFactory) Monitor.findServiceModule(this, LanguageConnectionFactory.MODULE);
74         PropertyFactory pf = lcf.getPropertyFactory();
75         if (pf != null)
76             pf.addPropertySetNotification(new LanguageDbPropertySetter());
77
78         emptySet = new GenericParameterValueSet(null, 0, false);
79     }
80
81     /**
82      * Stop this module. In this case, nothing needs to be done.
83      */

84
85     public void stop() {
86     }
87
88     /* LanguageFactory methods */
89
90     /**
91      * Factory method for getting a ParameterValueSet
92      *
93      * @see LanguageFactory#newParameterValueSet
94      */

95     public ParameterValueSet newParameterValueSet(ClassInspector ci, int numParms, boolean hasReturnParam)
96     {
97         if (numParms == 0)
98             return emptySet;
99
100         return new GenericParameterValueSet(ci, numParms, hasReturnParam);
101     }
102
103     /**
104      * Get a new result description from the input result
105      * description. Picks only the columns in the column
106      * array from the inputResultDescription.
107      *
108      * @param inputResultDescription the input rd
109      * @param theCols array of ints, non null
110      *
111      * @return ResultDescription the rd
112      */

113     public ResultDescription getResultDescription
114     (
115         ResultDescription inputResultDescription,
116         int[] theCols
117     )
118     {
119         return new GenericResultDescription(inputResultDescription, theCols);
120     }
121
122     /**
123      * Get a new result description
124      *
125      * @param cols an array of col descriptors
126      * @param type the statement type
127      *
128      * @return ResultDescription the rd
129      */

130     public ResultDescription getResultDescription
131     (
132         ResultColumnDescriptor[] cols,
133         String JavaDoc type
134     )
135     {
136         return new GenericResultDescription(cols, type);
137     }
138  
139     /*
140     ** REMIND: we will need a row and column factory
141     ** when we make putResultSets available for users'
142     ** server-side JDBC methods.
143     */

144 }
145
Popular Tags