Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 155   Methods: 5
NCLOC: 121   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
ASTPlSqlPrimaryExpression.java 0% 0% 0% 0%
coverage
 1   
 /* JJT:    0.2.2 */
 2   
 
 3   
 package    mobisnap.mobile_trx;
 4   
 
 5   
 
 6   
 /**
 7   
  * Implements primary sql expression : variables, numbers, ...
 8   
  */
 9   
 public class ASTPlSqlPrimaryExpression extends mobisnap.mobile_trx.SimpleNode {
 10   
     public static final byte EXPR_NULL = 0;
 11   
     public static final byte EXPR_CURSORFOUND = 1;
 12   
     public static final byte EXPR_CURSORNOTFOUND = 2;
 13   
     public static final byte EXPR_CURSORISOPEN = 3;
 14   
     public static final byte EXPR_CURSORROWCOUNT = 4;
 15   
     public static final byte EXPR_FUNCTION = 5;
 16   
     public static final byte EXPR_VARIABLE = 6;
 17   
     public static final byte EXPR_SQLCURSOR = 7;
 18   
     public static final byte EXPR_SQLNUMBER = 8;
 19   
     public static final byte EXPR_SQLCHARLITERAL = 9;
 20   
     public static final byte EXPR_SQLBIND = 10;
 21   
     public static final byte EXPR_SQLEXPR = 11;
 22   
     public static final byte EXPR_SYSDATE = 12;
 23   
     public static final byte EXPR_CURSYSDATE = 13;    //v1 = curdate
 24   
     public static final byte EXPR_NEWUID = 14;        //v1 = uid
 25   
     
 26   
     public byte type;
 27   
     public Object v1, v2;
 28   
 
 29  0
     public ASTPlSqlPrimaryExpression(int id) {
 30  0
         super(id);
 31   
     }
 32   
 
 33  0
     public ASTPlSqlPrimaryExpression( MobisnapSQL    p, int i) {
 34  0
         super( p, i);
 35  0
         id = i;
 36   
     }
 37   
 
 38   
     /** Accept the visitor. **/
 39  0
     public Object jjtAccept(MobisnapSQLVisitor visitor, Object data) {
 40  0
         return visitor.visit(this, data);
 41   
     }
 42   
     
 43   
     /**
 44   
      * Displays the source code of the node
 45   
      */
 46  0
     public void    sourceCode(    int msql_type, StringBuffer buffer) throws Exception {
 47  0
         if( msql_type == mobisnap.MobisnapConstants.MSQL_ORIGINAL) {
 48  0
             switch( type) {
 49   
             case EXPR_CURSYSDATE:
 50  0
                 buffer.append( "'");
 51  0
                 buffer.append( MSQLTypeUtil.date2String( (java.util.Date)v1));
 52  0
                 buffer.append( "'");
 53  0
                 break;
 54   
             case EXPR_NEWUID:
 55  0
                 buffer.append( "'");
 56  0
                 buffer.append( ((mobisnap.common.MobisnapUID)v1).toString());
 57  0
                 buffer.append( "'");
 58  0
                 break;
 59   
             default:
 60  0
                 super.sourceCode( msql_type, buffer);
 61  0
                 break;
 62   
             }
 63  0
             return;
 64   
         }
 65   
 
 66  0
         switch( type) {
 67   
         case EXPR_VARIABLE:
 68  0
             Object obj = MobisnapSQL.names.getName( (String)v1).getValue();
 69  0
             if( obj instanceof String) {
 70  0
                 buffer.append( "'");
 71  0
                 buffer.append( obj.toString());
 72  0
                 buffer.append( "'");
 73  0
             } else if( obj instanceof java.sql.Date)
 74  0
                 buffer.append( MSQLTypeUtil.date2String( (java.sql.Date)obj));
 75   
             else
 76  0
                 buffer.append( obj.toString());
 77  0
             break;
 78   
         case EXPR_SQLCHARLITERAL:
 79  0
             buffer.append( "'");
 80  0
             buffer.append( v1);
 81  0
             buffer.append( "'");
 82  0
             break;
 83   
         case EXPR_SYSDATE:
 84  0
             buffer.append( "'");
 85  0
             buffer.append( MSQLTypeUtil.date2String( new java.util.Date()));
 86  0
             buffer.append( "'");
 87  0
             break;
 88   
         case EXPR_CURSYSDATE:
 89  0
             buffer.append( "'");
 90  0
             buffer.append( MSQLTypeUtil.date2String( (java.util.Date)v1));
 91  0
             buffer.append( "'");
 92  0
             break;
 93   
         case EXPR_NEWUID:
 94  0
             buffer.append( "'");
 95  0
             buffer.append( ((mobisnap.common.MobisnapUID)v1).toString());
 96  0
             buffer.append( "'");
 97  0
             break;
 98   
         default:
 99  0
             super.sourceCode( msql_type, buffer);
 100  0
             break;
 101   
         }
 102   
     }
 103   
     
 104   
 
 105   
     
 106   
     /**
 107   
      * Returns the value of the expression
 108   
      * 
 109   
      * @param msql_type Specifies which type of processing should be performed
 110   
      *        MobisnapConstants.MSQL_SERVER = 1
 111   
      *        MobisnapConstants.MSQL_TENTATIVE_CLIENT = 2
 112   
      *        MobisnapConstants.MSQL_STABLE_CLIENT = 3
 113   
      *        MobisnapConstants.MSQL_RESERVATION_CLIENT = 4
 114   
      * @param cond True if reservations associated iwth transaction should be 
 115   
      * propagated to the current transaction
 116   
      */
 117  0
     public Object value( int msql_type, boolean cond) throws Exception {
 118  0
         switch( type) {
 119   
         case EXPR_NULL:
 120  0
             return new SQLNull();
 121   
         case EXPR_SQLNUMBER:
 122  0
             return MSQLTypeUtil.string2Decimal( (String)v1);
 123   
         case EXPR_VARIABLE:
 124  0
             if( msql_type == mobisnap.MobisnapConstants.MSQL_ORIGINAL)
 125  0
                 return v1;
 126  0
             MSQLTName var = null;
 127  0
             try {
 128  0
                 var = MobisnapSQL.names.getName( (String)v1);
 129   
             } catch( NoReservationException e) {
 130  0
                 throw e;
 131   
             } catch( Exception e) {
 132  0
                 var = null;
 133   
             }
 134  0
             if( var == null)
 135  0
                 throw new UnknownValueException( "Unknown variable");
 136   
             else
 137  0
                 return var.getValue();
 138   
         case EXPR_SQLCHARLITERAL:
 139  0
             return v1;
 140   
         case EXPR_SQLEXPR:
 141  0
             return ((ASTPlSqlExpression)v1).value( msql_type, cond);
 142   
         case EXPR_SYSDATE:
 143  0
             return new java.sql.Date( new java.util.Date().getTime());
 144   
         case EXPR_CURSYSDATE:
 145  0
             return v1;
 146   
         case EXPR_NEWUID:
 147  0
             return ((mobisnap.common.MobisnapUID)v1).toString();
 148   
         default:
 149  0
             throw new mobisnap.MobisnapException( "SqlPrimaryExpression error");
 150   
         }
 151   
     }
 152   
     
 153   
 
 154   
 }
 155