Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 102   Methods: 7
NCLOC: 59   Classes: 2
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
ASTSQLSimpleExpression.java 0% 0% 0% 0%
coverage
 1   
 /* JJT:    0.2.2 */
 2   
 
 3   
 package    mobisnap.mobile_trx;
 4   
 
 5   
 import java.util.*;
 6   
 
 7   
 /**
 8   
  * Implements simple expression
 9   
  */
 10   
 public class ASTSQLSimpleExpression extends mobisnap.mobile_trx.SimpleNode {
 11   
     public static final byte OP_PLUS = 0;
 12   
     public static final byte OP_MINUS = 1;
 13   
     public static final byte OP_OR = 2;
 14   
     
 15   
     public SimpleNode first;
 16   
     public Vector ors;
 17   
 
 18  0
     public ASTSQLSimpleExpression(int id) {
 19  0
         super(id);
 20  0
         ors = new Vector();
 21   
     }
 22   
 
 23  0
     public ASTSQLSimpleExpression( MobisnapSQL p, int i) {
 24  0
         super( p, i);
 25  0
         id = i;
 26  0
         ors = new Vector();
 27   
     }
 28   
     
 29   
     /** Accept the visitor. **/
 30  0
     public Object jjtAccept(MobisnapSQLVisitor visitor, Object data) {
 31  0
         return visitor.visit(this, data);
 32   
     }
 33   
     
 34   
     public class term {
 35   
         public byte opType;
 36   
         public SimpleNode expr;
 37   
         
 38  0
         public term( byte opType, ASTSQLMultiplicativeExpression expr) {
 39  0
             this.opType = opType;
 40  0
             this.expr = expr;
 41   
         }
 42   
     };
 43   
     
 44  0
     public void insert( byte opType, ASTSQLMultiplicativeExpression expr) {
 45  0
         ors.addElement( new term( opType, expr));
 46   
     }
 47   
     
 48   
     /**
 49   
      * Returns the value of the expression
 50   
      * 
 51   
      * @param msql_type Specifies which type of processing should be performed
 52   
      *        MobisnapConstants.MSQL_SERVER = 1
 53   
      *        MobisnapConstants.MSQL_TENTATIVE_CLIENT = 2
 54   
      *        MobisnapConstants.MSQL_STABLE_CLIENT = 3
 55   
      *        MobisnapConstants.MSQL_RESERVATION_CLIENT = 4
 56   
      *        MobisnapConstants.MSQL_STATIC = 10
 57   
      * @param cond True if reservations associated iwth transaction should be 
 58   
      * propagated to the current transaction
 59   
      */
 60  0
     public Object value( int msql_type, boolean cond) throws Exception {
 61  0
         Object val = first.value( msql_type, cond);
 62  0
         for( int i = 0; i < ors.size(); i++) {
 63  0
             term t = (term)ors.elementAt( i);
 64  0
             if( t.opType == OP_PLUS)
 65  0
                 val = MSQLTypeUtil.add( val, t.expr.value( msql_type, cond));
 66  0
             else if( t.opType == OP_MINUS)
 67  0
                 val = MSQLTypeUtil.subtract( val, t.expr.value( msql_type, cond));
 68   
             else
 69  0
                 val = MSQLTypeUtil.concat( val, t.expr.value( msql_type, cond));
 70   
         }
 71  0
         return val;
 72   
     }
 73   
 
 74   
     /**
 75   
      * Returns a simplified node, if possible (usefull in expressions)
 76   
      * 
 77   
      * @param msql_type Specifies which type of processing should be performed
 78   
      *        MobisnapConstants.MSQL_SERVER = 1
 79   
      *        MobisnapConstants.MSQL_TENTATIVE_CLIENT = 2
 80   
      *        MobisnapConstants.MSQL_STABLE_CLIENT = 3
 81   
      *        MobisnapConstants.MSQL_RESERVATION_CLIENT = 4
 82   
      *        MobisnapConstants.MSQL_STATIC = 10
 83   
      * @param cond True if reservations associated iwth transaction should be 
 84   
      * propagated to the current transaction
 85   
      */
 86  0
     public SimpleNode simplify( int msql_type, boolean cond) {
 87  0
         first = (SimpleNode)first.simplify( msql_type, cond);
 88  0
         for( int i = 0; i < ors.size(); i++) {
 89  0
             term t = (term)ors.elementAt( i);
 90  0
             t.expr = t.expr.simplify( msql_type, cond);
 91   
         }
 92  0
         if( ors.size() == 0)
 93  0
             return first;
 94  0
         try {
 95  0
             return new SimpleNodeValue( value( msql_type, cond));
 96   
         } catch( Exception e) {
 97  0
             return this;
 98   
         }
 99   
     }
 100   
 
 101   
 }
 102