Coverage Report - org.apache.ojb.broker.accesslayer.sql.SqlGeneratorFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
SqlGeneratorFactory
N/A
N/A
1.667
 
 1  
 package org.apache.ojb.broker.accesslayer.sql;
 2  
 
 3  
 /* Copyright 2002-2005 The Apache Software Foundation
 4  
  *
 5  
  * Licensed under the Apache License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 import org.apache.ojb.broker.util.factory.ConfigurableFactory;
 19  
 import org.apache.ojb.broker.platforms.Platform;
 20  
 
 21  
 import java.util.Map;
 22  
 import java.util.HashMap;
 23  
 
 24  
 /**
 25  
  * This factory creates SqlGenerator instances. it is a configurable factory and
 26  
  * can be used to generate user defined implementations too.
 27  
  * @author Thomas Mahler
 28  
  */
 29  
 public class SqlGeneratorFactory extends ConfigurableFactory
 30  
 {
 31  
         private static SqlGeneratorFactory instance = null;
 32  
 
 33  
     private Map generatorMap = new HashMap();
 34  
 
 35  
         /**
 36  
          * @see org.apache.ojb.broker.util.factory.ConfigurableFactory#getConfigurationKey()
 37  
          */
 38  
         protected String getConfigurationKey()
 39  
         {
 40  
                 return "SqlGeneratorClass";
 41  
         }
 42  
 
 43  
         public SqlGenerator createSqlGenerator(Platform pf)
 44  
         {
 45  
                 SqlGenerator gen = (SqlGenerator) generatorMap.get(pf.getClass().getName());
 46  
         if(gen == null)
 47  
         {
 48  
             gen = (SqlGenerator) this.createNewInstance(Platform.class, pf);
 49  
             generatorMap.put(pf.getClass(), gen);
 50  
         }
 51  
         return gen;
 52  
         }
 53  
 
 54  
         public static SqlGeneratorFactory getInstance()
 55  
         {
 56  
                 if (instance == null)
 57  
                 {
 58  
                         instance = new SqlGeneratorFactory();
 59  
                 }
 60  
                 return instance;
 61  
         }
 62  
 }