Coverage Report - net.wotonomy.jdbcadaptor.JDBCAdaptor
 
Classes in this File Line Coverage Branch Coverage Complexity
JDBCAdaptor
0% 
0% 
1.556
 
 1  
 /*
 2  
  Wotonomy: OpenStep design patterns for pure Java applications.
 3  
  Copyright (C) 2001 Michael Powers
 4  
 
 5  
  This library is free software; you can redistribute it and/or
 6  
  modify it under the terms of the GNU Lesser General Public
 7  
  License as published by the Free Software Foundation; either
 8  
  version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
  This library is distributed in the hope that it will be useful,
 11  
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  Lesser General Public License for more details.
 14  
 
 15  
  You should have received a copy of the GNU Lesser General Public
 16  
  License along with this library; if not, see http://www.gnu.org
 17  
  */
 18  
 package net.wotonomy.jdbcadaptor;
 19  
 
 20  
 import net.wotonomy.access.EOAdaptor;
 21  
 import net.wotonomy.access.EOAdaptorContext;
 22  
 import net.wotonomy.access.EOModel;
 23  
 import net.wotonomy.access.EOSQLExpressionFactory;
 24  
 import net.wotonomy.foundation.NSDictionary;
 25  
 
 26  
 
 27  
 /**
 28  
 * An adaptor that connects to a databaser server via JDBC.
 29  
 *
 30  
 * @author ezamudio@nasoft.com
 31  
 * @author $Author: cgruber $
 32  
 * @version $Revision: 903 $
 33  
 */
 34  
 public class JDBCAdaptor extends EOAdaptor {
 35  
 
 36  
         protected EOSQLExpressionFactory _expressionFactory;
 37  
         protected String _driverName;
 38  
         protected NSDictionary _jdbcInfo;
 39  
 
 40  
         /**
 41  
          * Creates a new instance.
 42  
          * @param name The name of the adaptor (should always be JDBC)
 43  
          */
 44  
         public JDBCAdaptor(String name) {
 45  0
                 super(name);
 46  0
         }
 47  
 
 48  
         public void setConnectionDictionary(NSDictionary dict) {
 49  0
                 super.setConnectionDictionary(dict);
 50  0
                 if (dict.objectForKey("driver") != null)
 51  0
                         _driverName = (String)dict.objectForKey("driver");
 52  
                 else
 53  0
                         throw new JDBCAdaptorException("Connection dictionary must have a 'driver' key.", null);
 54  0
                 if (dict.objectForKey("jdbc2Info") != null)
 55  0
                         _jdbcInfo = (NSDictionary)dict.objectForKey("jdbc2Info");
 56  
                 else
 57  0
                         throw new JDBCAdaptorException("Connection dictionary must have a 'jdbc2Info' key.", null);
 58  0
         }
 59  
 
 60  
         /* Checks to see if the connection dictionary is valid.
 61  
          * Throws an exception if it's not.
 62  
          * @see net.wotonomy.access.EOAdaptor#assertConnectionDictionaryIsValid()
 63  
          */
 64  
         public void assertConnectionDictionaryIsValid() {
 65  0
                 JDBCContext context = new JDBCContext(this);
 66  0
                 context.connect();
 67  0
                 context.disconnect();
 68  0
         }
 69  
 
 70  
         /* Creates a JDBCContext.
 71  
          * @see net.wotonomy.access.EOAdaptor#createAdaptorContext()
 72  
          */
 73  
         public EOAdaptorContext createAdaptorContext() {
 74  0
                 JDBCContext context = new JDBCContext(this);
 75  0
                 _contexts.addObject(context);
 76  0
                 return context;
 77  
         }
 78  
 
 79  
         /* Returns the JDBCExpression class.
 80  
          * @see net.wotonomy.access.EOAdaptor#defaultExpressionClass()
 81  
          */
 82  
         public Class defaultExpressionClass() {
 83  0
                 return JDBCExpression.class;
 84  
         }
 85  
 
 86  
         /* Returns a JDBCExpressionFactory.
 87  
          * @see net.wotonomy.access.EOAdaptor#expressionFactory()
 88  
          */
 89  
         public EOSQLExpressionFactory expressionFactory() {
 90  0
                 if (_expressionFactory == null)
 91  0
                         _expressionFactory = new JDBCExpressionFactory(this);
 92  0
                 return _expressionFactory;
 93  
         }
 94  
 
 95  
         /* Determines if a qualifier type is valid.
 96  
          * @see net.wotonomy.access.EOAdaptor#isValidQualifierType(java.lang.String, net.wotonomy.access.EOModel)
 97  
          */
 98  
         public boolean isValidQualifierType(String typeName, EOModel model) {
 99  
                 // TODO Auto-generated method stub
 100  0
                 return false;
 101  
         }
 102  
 
 103  
         public String driverName() {
 104  0
                 return _driverName;
 105  
         }
 106  
 
 107  
         public NSDictionary jdbcInfo() {
 108  0
                 return _jdbcInfo;
 109  
         }
 110  
 
 111  
 }
 112  
 /*
 113  
  * $Log$
 114  
  * Revision 1.2  2006/02/18 22:59:22  cgruber
 115  
  * make it compile with maven dependencies and add a cvsignore.
 116  
  *
 117  
  * Revision 1.1  2006/02/16 13:22:23  cgruber
 118  
  * Check in all sources in eclipse-friendly maven-enabled packages.
 119  
  *
 120  
  * Revision 1.1  2003/08/13 20:09:37  chochos
 121  
  * a concrete implementation of EOAdaptor for use with JDBC
 122  
  *
 123  
  */