Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 108   Methods: 6
NCLOC: 65   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
EscrowReservationUse.java 0% 0% 0% 0%
coverage
 1   
 package mobisnap.common.reservation;
 2   
 
 3   
 import mobisnap.mobile_trx.*;
 4   
 
 5   
 /**
 6   
  * Used to represent the usage of a escrow reservation
 7   
  * 
 8   
  * @version 0.045 12-Dec-2000
 9   
  * @author Nuno Pregui�a
 10   
  */
 11   
 public class EscrowReservationUse
 12   
     extends ReservationUseBase
 13   
     implements java.io.Serializable
 14   
 {
 15   
     Object used;
 16   
     transient boolean srvPreOK = false;
 17   
     
 18  0
     public EscrowReservationUse( EscrowReservation rsrv) {
 19  0
         super( rsrv);
 20  0
         used = new Integer( 0);
 21   
     }
 22   
     
 23   
     /**
 24   
      * Increases the number of used instances in the given reservation
 25   
      */
 26  0
     public void addUsed( Object val) throws Exception {
 27  0
         used = mobisnap.mobile_trx.MSQLTypeUtil.add( used, val);
 28  0
         Object bool = MSQLTypeUtil.moreEqual( ((EscrowReservation)rsrv).instances, used);
 29  0
         if( ! ( bool != null && bool instanceof Boolean  && ((Boolean)bool).booleanValue()))
 30  0
             throw new NoReservationException( "Reservation overflowed");
 31   
     }
 32   
 
 33   
     /**
 34   
      * The associated transaction has been committed. Updates the associated
 35   
      * reservation accordingly.
 36   
      * Returns true if the reservation has been completely used
 37   
      */
 38  0
     public boolean commitCltRsrv() throws Exception {
 39  0
         EscrowReservation rsrv = (EscrowReservation)this.rsrv;
 40  0
         rsrv.instances = MSQLTypeUtil.subtract( rsrv.instances, used);
 41  0
         Object bool = MSQLTypeUtil.equal( new Integer( 0), rsrv.instances);
 42  0
         return ! ( bool != null && bool instanceof Boolean  && ! ((Boolean)bool).booleanValue());
 43   
     }
 44   
 
 45   
     /**
 46   
      * The associated transaction has been rollbacked. Updates the associated
 47   
      * reservation accordingly.
 48   
      */
 49  0
     public void rollbackCltRsrv(){
 50   
         // do nothing
 51   
     }
 52   
 
 53   
 
 54   
     /**
 55   
      * Updates the reservation and database according to the current usage - processed
 56   
      * BEFORE the transaction execution.
 57   
      * Returns false if the current usage is not compatoble with the associated
 58   
      * reservation.
 59   
      */
 60  0
     public boolean preSrvTrxExeUpdate( ReservationBase rsrv0, nmp.dbms.JDBC.Jdbc_Sql database) throws Exception {
 61  0
         if( ! ( rsrv0 instanceof EscrowReservation)) 
 62  0
             throw new mobisnap.MobisnapException( "Escrow reservation expected in preSrvTrxExeUpdate");
 63  0
         EscrowReservation rsrv = (EscrowReservation)rsrv0;
 64  0
         Object bool = MSQLTypeUtil.moreEqual( rsrv.instances, used);
 65  0
         if( bool == null || ! ( bool instanceof Boolean) || ! ((Boolean)bool).booleanValue())
 66  0
             return false;
 67  0
         srvPreOK = true;
 68  0
         rsrv.instances = MSQLTypeUtil.subtract( rsrv.instances, used);
 69   
         
 70  0
         StringBuffer buffer = new StringBuffer();
 71  0
         buffer.append( "update ");
 72  0
         buffer.append( rsrv.table);
 73  0
         buffer.append( " set ");
 74  0
         buffer.append( rsrv.column);
 75  0
         buffer.append( " = ");
 76  0
         buffer.append( rsrv.column);
 77  0
         buffer.append( " + ");
 78  0
         buffer.append( MSQLTypeUtil.value2String( used));
 79  0
         buffer.append( " where ");
 80  0
         int ncond = rsrv.conds.size();
 81  0
         for( int i = 0; i < ncond; i++) {
 82  0
             if( i != 0)
 83  0
                 buffer.append( " AND ");
 84  0
             ColumnCondition cond = (ColumnCondition)rsrv.conds.elementAt( i);
 85  0
             cond.sourceCode( buffer);
 86   
         }
 87  0
         buffer.append( ";");
 88  0
         if( database.executeUpdate( buffer.toString()) != 1)
 89  0
             return false;
 90  0
         return true;
 91   
     }
 92   
 
 93   
     /**
 94   
      * Updates the reservation and database according to the current usage - processed
 95   
      * AFTER the transaction execution.
 96   
      * Returns true if the transaction has been completely used.
 97   
      */
 98  0
     public boolean postSrvTrxExeUpdate( ReservationBase rsrv0, nmp.dbms.JDBC.Jdbc_Sql database) throws Exception {
 99  0
         if( ! ( rsrv0 instanceof EscrowReservation)) 
 100  0
             throw new mobisnap.MobisnapException( "Escrow reservation expected in preSrvTrxExeUpdate");
 101  0
         EscrowReservation rsrv = (EscrowReservation)rsrv0;
 102  0
         Object bool = MSQLTypeUtil.moreEqual( rsrv.instances, new Integer( 0));
 103  0
         return bool == null || ! ( bool instanceof Boolean) || ! ((Boolean)bool).booleanValue();
 104   
     }
 105   
 
 106   
     
 107   
 }
 108