Clover coverage report - Ledge Components - SNAPSHOT
Coverage timestamp: Fri Nov 17 2006 05:13:20 CET
file stats: LOC: 857   Methods: 83
NCLOC: 485   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DelegatingCallableStatement.java 0% 0% 0% 0%
coverage
 1    //
 2    // Copyright (c) 2003-2005, Caltha - Gajda, Krzewski, Mach, Potempski Sp.J.
 3    // All rights reserved.
 4    //
 5    // Redistribution and use in source and binary forms, with or without modification,
 6    // are permitted provided that the following conditions are met:
 7    //
 8    // * Redistributions of source code must retain the above copyright notice,
 9    // this list of conditions and the following disclaimer.
 10    // * Redistributions in binary form must reproduce the above copyright notice,
 11    // this list of conditions and the following disclaimer in the documentation
 12    // and/or other materials provided with the distribution.
 13    // * Neither the name of the Caltha - Gajda, Krzewski, Mach, Potempski Sp.J.
 14    // nor the names of its contributors may be used to endorse or promote products
 15    // derived from this software without specific prior written permission.
 16    //
 17    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 18    // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 19    // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 20    // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 21    // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 22    // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 23    // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 24    // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 25    // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 26    // POSSIBILITY OF SUCH DAMAGE.
 27    //
 28   
 29    package org.objectledge.database.impl;
 30   
 31    import java.io.InputStream;
 32    import java.io.Reader;
 33    import java.math.BigDecimal;
 34    import java.net.URL;
 35    import java.sql.Array;
 36    import java.sql.Blob;
 37    import java.sql.CallableStatement;
 38    import java.sql.Clob;
 39    import java.sql.Date;
 40    import java.sql.Ref;
 41    import java.sql.SQLException;
 42    import java.sql.Time;
 43    import java.sql.Timestamp;
 44    import java.util.Calendar;
 45    import java.util.HashMap;
 46    import java.util.List;
 47    import java.util.Map;
 48   
 49    /**
 50    * A delegation pattern wrapper for java.sql.CallableStatement.
 51    *
 52    * @author <a href="rafal@caltha.pl">RafaƂ Krzewski</a>
 53    * @version $Id: DelegatingCallableStatement.java,v 1.2 2005/10/10 08:27:46 rafal Exp $
 54    */
 55    @SuppressWarnings("deprecation")
 56    public class DelegatingCallableStatement
 57    extends DelegatingPreparedStatement
 58    implements CallableStatement
 59    {
 60   
 61    private final CallableStatement callableStatement;
 62   
 63    private final Map<String, Object> parameterMap = new HashMap<String, Object>();
 64   
 65    /**
 66    * Creates a new DelegatingCallableStatement instance.
 67    *
 68    * @param callableStatement the delegate callable statement.
 69    * @param sql the statement body.
 70    */
 71  0 public DelegatingCallableStatement(CallableStatement callableStatement, String sql)
 72    {
 73  0 super(callableStatement, sql);
 74  0 this.callableStatement = callableStatement;
 75    }
 76   
 77  0 private void setParameter(String parameterName, Object value)
 78    {
 79  0 parameterMap.put(parameterName, value);
 80    }
 81   
 82    /**
 83    * {@inheritDoc}
 84    */
 85  0 @Override
 86    protected void clearParameters2()
 87    {
 88  0 super.clearParameters2();
 89  0 parameterMap.clear();
 90    }
 91   
 92    /**
 93    * {@inheritDoc}
 94    */
 95  0 @Override
 96    protected String getBody()
 97    {
 98  0 List<Object> parameterList = getParameterList();
 99  0 StringBuilder body = new StringBuilder();
 100  0 body.append(getSQL());
 101  0 if(!parameterList.isEmpty() || !parameterMap.isEmpty())
 102    {
 103  0 body.append(" with ");
 104    }
 105  0 if(!parameterList.isEmpty())
 106    {
 107  0 body.append(parameterList.toString());
 108    }
 109  0 if(!parameterList.isEmpty() && !parameterMap.isEmpty())
 110    {
 111  0 body.append(", ");
 112    }
 113  0 if(!parameterMap.isEmpty())
 114    {
 115  0 body.append(parameterMap.toString());
 116    }
 117  0 return body.toString();
 118    }
 119   
 120    // .. CallableStatement .....................................................................
 121   
 122    /**
 123    * {@inheritDoc}
 124    */
 125  0 public void registerOutParameter(int parameterIndex, int sqlType)
 126    throws SQLException
 127    {
 128  0 callableStatement.registerOutParameter(parameterIndex, sqlType);
 129    }
 130   
 131    /**
 132    * {@inheritDoc}
 133    */
 134  0 public void registerOutParameter(int parameterIndex, int sqlType, int scale)
 135    throws SQLException
 136    {
 137  0 callableStatement.registerOutParameter(parameterIndex, sqlType, scale);
 138    }
 139   
 140    /**
 141    * {@inheritDoc}
 142    */
 143  0 public void registerOutParameter(int paramIndex, int sqlType, String typeName)
 144    throws SQLException
 145    {
 146  0 callableStatement.registerOutParameter(paramIndex, sqlType, typeName);
 147    }
 148   
 149    /**
 150    * {@inheritDoc}
 151    */
 152  0 public void registerOutParameter(String parameterName, int sqlType)
 153    throws SQLException
 154    {
 155  0 callableStatement.registerOutParameter(parameterName, sqlType);
 156    }
 157   
 158    /**
 159    * {@inheritDoc}
 160    */
 161  0 public void registerOutParameter(String parameterName, int sqlType, int scale)
 162    throws SQLException
 163    {
 164  0 callableStatement.registerOutParameter(parameterName, sqlType, scale);
 165    }
 166   
 167    /**
 168    * {@inheritDoc}
 169    */
 170  0 public void registerOutParameter(String parameterName, int sqlType, String typeName)
 171    throws SQLException
 172    {
 173  0 callableStatement.registerOutParameter(parameterName, sqlType, typeName);
 174    }
 175   
 176    /**
 177    * {@inheritDoc}
 178    */
 179  0 public boolean wasNull()
 180    throws SQLException
 181    {
 182  0 return callableStatement.wasNull();
 183    }
 184   
 185    /**
 186    * {@inheritDoc}
 187    */
 188  0 public String getString(int parameterIndex)
 189    throws SQLException
 190    {
 191  0 return callableStatement.getString(parameterIndex);
 192    }
 193   
 194    /**
 195    * {@inheritDoc}
 196    */
 197  0 public boolean getBoolean(int parameterIndex)
 198    throws SQLException
 199    {
 200  0 return callableStatement.getBoolean(parameterIndex);
 201    }
 202   
 203    /**
 204    * {@inheritDoc}
 205    */
 206  0 public byte getByte(int parameterIndex)
 207    throws SQLException
 208    {
 209  0 return callableStatement.getByte(parameterIndex);
 210    }
 211   
 212    /**
 213    * {@inheritDoc}
 214    */
 215  0 public short getShort(int parameterIndex)
 216    throws SQLException
 217    {
 218  0 return callableStatement.getShort(parameterIndex);
 219    }
 220   
 221    /**
 222    * {@inheritDoc}
 223    */
 224  0 public int getInt(int parameterIndex)
 225    throws SQLException
 226    {
 227  0 return callableStatement.getInt(parameterIndex);
 228    }
 229   
 230    /**
 231    * {@inheritDoc}
 232    */
 233  0 public long getLong(int parameterIndex)
 234    throws SQLException
 235    {
 236  0 return callableStatement.getLong(parameterIndex);
 237    }
 238   
 239    /**
 240    * {@inheritDoc}
 241    */
 242  0 public float getFloat(int parameterIndex)
 243    throws SQLException
 244    {
 245  0 return callableStatement.getFloat(parameterIndex);
 246    }
 247   
 248    /**
 249    * {@inheritDoc}
 250    */
 251  0 public double getDouble(int parameterIndex)
 252    throws SQLException
 253    {
 254  0 return callableStatement.getDouble(parameterIndex);
 255    }
 256   
 257    /**
 258    * {@inheritDoc}
 259    */
 260  0 public BigDecimal getBigDecimal(int parameterIndex)
 261    throws SQLException
 262    {
 263  0 return callableStatement.getBigDecimal(parameterIndex);
 264    }
 265   
 266    /**
 267    * {@inheritDoc}
 268    */
 269  0 public BigDecimal getBigDecimal(int parameterIndex, int scale)
 270    throws SQLException
 271    {
 272  0 return callableStatement.getBigDecimal(parameterIndex, scale);
 273    }
 274   
 275    /**
 276    * {@inheritDoc}
 277    */
 278  0 public byte[] getBytes(int parameterIndex)
 279    throws SQLException
 280    {
 281  0 return callableStatement.getBytes(parameterIndex);
 282    }
 283   
 284    /**
 285    * {@inheritDoc}
 286    */
 287  0 public Date getDate(int parameterIndex)
 288    throws SQLException
 289    {
 290  0 return callableStatement.getDate(parameterIndex);
 291    }
 292   
 293    /**
 294    * {@inheritDoc}
 295    */
 296  0 public Time getTime(int parameterIndex)
 297    throws SQLException
 298    {
 299  0 return callableStatement.getTime(parameterIndex);
 300    }
 301   
 302    /**
 303    * {@inheritDoc}
 304    */
 305  0 public Timestamp getTimestamp(int parameterIndex)
 306    throws SQLException
 307    {
 308  0 return callableStatement.getTimestamp(parameterIndex);
 309    }
 310   
 311    /**
 312    * {@inheritDoc}
 313    */
 314  0 public Object getObject(int parameterIndex)
 315    throws SQLException
 316    {
 317  0 return callableStatement.getObject(parameterIndex);
 318    }
 319   
 320    /**
 321    * {@inheritDoc}
 322    */
 323  0 public Object getObject(int parameterIndex, Map<String, Class<?>> typeMap)
 324    throws SQLException
 325    {
 326  0 return callableStatement.getObject(parameterIndex, typeMap);
 327    }
 328   
 329    /**
 330    * {@inheritDoc}
 331    */
 332  0 public Ref getRef(int i)
 333    throws SQLException
 334    {
 335  0 return callableStatement.getRef(i);
 336    }
 337   
 338    /**
 339    * {@inheritDoc}
 340    */
 341  0 public Blob getBlob(int i)
 342    throws SQLException
 343    {
 344  0 return callableStatement.getBlob(i);
 345    }
 346   
 347    /**
 348    * {@inheritDoc}
 349    */
 350  0 public Clob getClob(int i)
 351    throws SQLException
 352    {
 353  0 return callableStatement.getClob(i);
 354    }
 355   
 356    /**
 357    * {@inheritDoc}
 358    */
 359  0 public Array getArray(int i)
 360    throws SQLException
 361    {
 362  0 return callableStatement.getArray(i);
 363    }
 364   
 365    /**
 366    * {@inheritDoc}
 367    */
 368  0 public Date getDate(int parameterIndex, Calendar cal)
 369    throws SQLException
 370    {
 371  0 return callableStatement.getDate(parameterIndex, cal);
 372    }
 373   
 374    /**
 375    * {@inheritDoc}
 376    */
 377  0 public Time getTime(int parameterIndex, Calendar cal)
 378    throws SQLException
 379    {
 380  0 return callableStatement.getTime(parameterIndex, cal);
 381    }
 382   
 383    /**
 384    * {@inheritDoc}
 385    */
 386  0 public Timestamp getTimestamp(int parameterIndex, Calendar cal)
 387    throws SQLException
 388    {
 389  0 return callableStatement.getTimestamp(parameterIndex, cal);
 390    }
 391   
 392    /**
 393    * {@inheritDoc}
 394    */
 395  0 public URL getURL(int parameterIndex)
 396    throws SQLException
 397    {
 398  0 return callableStatement.getURL(parameterIndex);
 399    }
 400   
 401    /**
 402    * {@inheritDoc}
 403    */
 404  0 public String getString(String parameterName)
 405    throws SQLException
 406    {
 407  0 return callableStatement.getString(parameterName);
 408    }
 409   
 410    /**
 411    * {@inheritDoc}
 412    */
 413  0 public boolean getBoolean(String parameterName)
 414    throws SQLException
 415    {
 416  0 return callableStatement.getBoolean(parameterName);
 417    }
 418   
 419    /**
 420    * {@inheritDoc}
 421    */
 422  0 public byte getByte(String parameterName)
 423    throws SQLException
 424    {
 425  0 return callableStatement.getByte(parameterName);
 426    }
 427   
 428    /**
 429    * {@inheritDoc}
 430    */
 431  0 public short getShort(String parameterName)
 432    throws SQLException
 433    {
 434  0 return callableStatement.getShort(parameterName);
 435    }
 436   
 437    /**
 438    * {@inheritDoc}
 439    */
 440  0 public int getInt(String parameterName)
 441    throws SQLException
 442    {
 443  0 return callableStatement.getInt(parameterName);
 444    }
 445   
 446    /**
 447    * {@inheritDoc}
 448    */
 449  0 public long getLong(String parameterName)
 450    throws SQLException
 451    {
 452  0 return callableStatement.getLong(parameterName);
 453    }
 454   
 455    /**
 456    * {@inheritDoc}
 457    */
 458  0 public float getFloat(String parameterName)
 459    throws SQLException
 460    {
 461  0 return callableStatement.getFloat(parameterName);
 462    }
 463   
 464    /**
 465    * {@inheritDoc}
 466    */
 467  0 public double getDouble(String parameterName)
 468    throws SQLException
 469    {
 470  0 return callableStatement.getDouble(parameterName);
 471    }
 472   
 473    /**
 474    * {@inheritDoc}
 475    */
 476  0 public byte[] getBytes(String parameterName)
 477    throws SQLException
 478    {
 479  0 return callableStatement.getBytes(parameterName);
 480    }
 481   
 482    /**
 483    * {@inheritDoc}
 484    */
 485  0 public Date getDate(String parameterName)
 486    throws SQLException
 487    {
 488  0 return callableStatement.getDate(parameterName);
 489    }
 490   
 491    /**
 492    * {@inheritDoc}
 493    */
 494  0 public Time getTime(String parameterName)
 495    throws SQLException
 496    {
 497  0 return callableStatement.getTime(parameterName);
 498    }
 499   
 500    /**
 501    * {@inheritDoc}
 502    */
 503  0 public Timestamp getTimestamp(String parameterName)
 504    throws SQLException
 505    {
 506  0 return callableStatement.getTimestamp(parameterName);
 507    }
 508   
 509    /**
 510