Coverage Report - org.mule.transport.jdbc.sqlstrategy.DefaultSqlStatementStrategyFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultSqlStatementStrategyFactory
0%
0/13
0%
0/12
4.5
 
 1  
 /*
 2  
  * $Id: DefaultSqlStatementStrategyFactory.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.transport.jdbc.sqlstrategy;
 12  
 
 13  
 public class DefaultSqlStatementStrategyFactory implements SqlStatementStrategyFactory
 14  
 {
 15  
     protected SimpleUpdateSqlStatementStrategy simpleUpdateSQLStrategy;
 16  
     protected SelectSqlStatementStrategy selectSQLStrategy;
 17  
     protected CallableSqlStatementStrategy callableSQLStrategy;
 18  
 
 19  
     public DefaultSqlStatementStrategyFactory()
 20  0
     {
 21  0
         simpleUpdateSQLStrategy = new SimpleUpdateSqlStatementStrategy();
 22  0
         selectSQLStrategy = new SelectSqlStatementStrategy();
 23  0
         callableSQLStrategy = new CallableSqlStatementStrategy();
 24  0
     }
 25  
 
 26  
     public SqlStatementStrategy create(String sql, Object payload)
 27  
         throws Exception
 28  
     {
 29  0
         String sqlLowerCase = sql.toLowerCase();
 30  
 
 31  0
         if( sqlLowerCase.startsWith("insert") ||
 32  
             sqlLowerCase.startsWith("update") ||
 33  
             sqlLowerCase.startsWith("delete") ||
 34  
             sqlLowerCase.startsWith("merge"))
 35  
         {
 36  0
             return simpleUpdateSQLStrategy;
 37  
         }
 38  
 
 39  0
         if (sqlLowerCase.startsWith("select"))
 40  
         {
 41  0
             return selectSQLStrategy;
 42  
         }
 43  
 
 44  0
         if (sqlLowerCase.startsWith("call"))
 45  
         {
 46  0
             return callableSQLStrategy;
 47  
         }
 48  
 
 49  0
         throw new IllegalArgumentException("No SQL Strategy found for SQL statement: " + sql);
 50  
     }
 51  
 
 52  
 }