001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.GenericLanguageFactory
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql;
023:
024: import org.apache.derby.iapi.services.property.PropertyFactory;
025: import org.apache.derby.iapi.store.access.AccessFactory;
026: import org.apache.derby.iapi.store.access.TransactionController;
027: import org.apache.derby.iapi.sql.LanguageFactory;
028: import org.apache.derby.iapi.sql.ParameterValueSet;
029: import org.apache.derby.iapi.sql.ResultDescription;
030: import org.apache.derby.iapi.sql.ResultColumnDescriptor;
031: import org.apache.derby.iapi.sql.Row;
032:
033: import org.apache.derby.iapi.services.monitor.Monitor;
034: import org.apache.derby.iapi.services.monitor.ModuleControl;
035: import org.apache.derby.iapi.error.StandardException;
036:
037: import org.apache.derby.iapi.sql.conn.LanguageConnectionFactory;
038: import org.apache.derby.iapi.services.loader.ClassInspector;
039:
040: import org.apache.derby.iapi.services.io.FormatIdUtil;
041:
042: import java.util.Properties;
043:
044: /**
045: The LanguageFactory provides system-wide services that
046: are available on the Database API.
047:
048: @author ames
049: */
050: public class GenericLanguageFactory implements LanguageFactory,
051: ModuleControl {
052:
053: private GenericParameterValueSet emptySet;
054:
055: public GenericLanguageFactory() {
056: }
057:
058: /*
059: ModuleControl interface
060: */
061:
062: /**
063: * Start-up method for this instance of the language factory.
064: * This service is expected to be started and accessed relative
065: * to a database.
066: *
067: * @param startParams The start-up parameters (ignored in this case)
068:
069: @exception StandardException Thrown if module cannot be booted.
070: *
071: */
072: public void boot(boolean create, Properties startParams)
073: throws StandardException {
074: LanguageConnectionFactory lcf = (LanguageConnectionFactory) Monitor
075: .findServiceModule(this ,
076: LanguageConnectionFactory.MODULE);
077: PropertyFactory pf = lcf.getPropertyFactory();
078: if (pf != null)
079: pf
080: .addPropertySetNotification(new LanguageDbPropertySetter());
081:
082: emptySet = new GenericParameterValueSet(null, 0, false);
083: }
084:
085: /**
086: * Stop this module. In this case, nothing needs to be done.
087: */
088:
089: public void stop() {
090: }
091:
092: /* LanguageFactory methods */
093:
094: /**
095: * Factory method for getting a ParameterValueSet
096: *
097: * @see LanguageFactory#newParameterValueSet
098: */
099: public ParameterValueSet newParameterValueSet(ClassInspector ci,
100: int numParms, boolean hasReturnParam) {
101: if (numParms == 0)
102: return emptySet;
103:
104: return new GenericParameterValueSet(ci, numParms,
105: hasReturnParam);
106: }
107:
108: /**
109: * Get a new result description from the input result
110: * description. Picks only the columns in the column
111: * array from the inputResultDescription.
112: *
113: * @param inputResultDescription the input rd
114: * @param theCols array of ints, non null
115: *
116: * @return ResultDescription the rd
117: */
118: public ResultDescription getResultDescription(
119: ResultDescription inputResultDescription, int[] theCols) {
120: return new GenericResultDescription(inputResultDescription,
121: theCols);
122: }
123:
124: /**
125: * Get a new result description
126: *
127: * @param cols an array of col descriptors
128: * @param type the statement type
129: *
130: * @return ResultDescription the rd
131: */
132: public ResultDescription getResultDescription(
133: ResultColumnDescriptor[] cols, String type) {
134: return new GenericResultDescription(cols, type);
135: }
136:
137: /*
138: ** REMIND: we will need a row and column factory
139: ** when we make putResultSets available for users'
140: ** server-side JDBC methods.
141: */
142: }
|