Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 103   Methods: 5
NCLOC: 63   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
ASTSQLRelationalExpression.java 0% 0% 0% 0%
coverage
 1   
 /* JJT:    0.2.2 */
 2   
 
 3   
 package    mobisnap.mobile_trx;
 4   
 
 5   
 /**
 6   
  * Implements relational expression
 7   
  */
 8   
 public class ASTSQLRelationalExpression extends    mobisnap.mobile_trx.SimpleNode {
 9   
     public SimpleNode first;
 10   
     public boolean firstprior = false;
 11   
     public byte type;                // 0 -> just first expression;  1 -> first relop(v1) v2
 12   
                                     // 2 -> in clause; 3 -> between clause
 13   
                                     // 4 -> like clause; 5 -> is null clause
 14   
     public Object v1, v2;
 15   
     public boolean secondprior = false;
 16   
     public boolean secondquery = false;
 17   
 
 18  0
     public ASTSQLRelationalExpression(int id) {
 19  0
         super(id);
 20   
     }
 21   
 
 22  0
     public ASTSQLRelationalExpression( MobisnapSQL p, int i) {
 23  0
         super( p, i);
 24  0
         id = i;
 25   
     }
 26   
     
 27   
     /** Accept the visitor. **/
 28  0
     public Object jjtAccept(MobisnapSQLVisitor visitor, Object data) {
 29  0
         return visitor.visit(this, data);
 30   
     }
 31   
     
 32   
     /**
 33   
      * Returns the value of the expression
 34   
      * 
 35   
      * @param msql_type Specifies which type of processing should be performed
 36   
      *        MobisnapConstants.MSQL_SERVER = 1
 37   
      *        MobisnapConstants.MSQL_TENTATIVE_CLIENT = 2
 38   
      *        MobisnapConstants.MSQL_STABLE_CLIENT = 3
 39   
      *        MobisnapConstants.MSQL_RESERVATION_CLIENT = 4
 40   
      * @param cond True if reservations associated iwth transaction should be 
 41   
      * propagated to the current transaction
 42   
      */
 43  0
     public Object value( int msql_type, boolean cond) throws Exception {
 44  0
         if( firstprior)
 45  0
             throw new UnknownValueException( "Prior not supported in SQLRelationalExpression");
 46  0
         if( type == 0)
 47  0
             return first.value( msql_type, cond);
 48  0
         if( type > 1)
 49  0
             throw new UnknownValueException( "Not a simple comparison");
 50  0
         if( secondprior)
 51  0
             throw new UnknownValueException( "Prior not supported in SQLRelationalExpression");
 52  0
         if( secondquery)
 53  0
             throw new UnknownValueException( "Subquery not supported in SQLRelationalExpression");
 54  0
         ASTRelop op = (ASTRelop)v1;
 55  0
         switch( op.type) {
 56   
         case ASTRelop.OP_EQUAL:
 57  0
             return MSQLTypeUtil.equal( first.value( msql_type, cond), ((ASTSQLSimpleExpression)v2).value( msql_type, cond));
 58   
         case ASTRelop.OP_NOTEQUAL:
 59  0
             return MSQLTypeUtil.notEqual( first.value( msql_type, cond), ((ASTSQLSimpleExpression)v2).value( msql_type, cond));
 60   
 /*        case ASTRelop.OP_CARDINAL:
 61   
             return MSQLTypeUtil.cardinal( first.value( msql_type, cond), ((ASTSQLSimpleExpression)v2).value( msql_type, cond));
 62   
 */        case ASTRelop.OP_MOREORLESS:
 63  0
             return MSQLTypeUtil.moreOrLess( first.value( msql_type, cond), ((ASTSQLSimpleExpression)v2).value( msql_type, cond));
 64   
         case ASTRelop.OP_MORE:
 65  0
             return MSQLTypeUtil.more( first.value( msql_type, cond), ((ASTSQLSimpleExpression)v2).value( msql_type, cond));
 66   
         case ASTRelop.OP_MOREEQUAL:
 67  0
             return MSQLTypeUtil.moreEqual( first.value( msql_type, cond), ((ASTSQLSimpleExpression)v2).value( msql_type, cond));
 68   
         case ASTRelop.OP_LESS:
 69  0
             return MSQLTypeUtil.less( first.value( msql_type, cond), ((ASTSQLSimpleExpression)v2).value( msql_type, cond));
 70   
         case ASTRelop.OP_LESSEQUAL:
 71  0
             return MSQLTypeUtil.lessEqual( first.value( msql_type, cond), ((ASTSQLSimpleExpression)v2).value( msql_type, cond));
 72   
         default:
 73  0
             throw new mobisnap.MobisnapException( "Internal error 1 in relational expression");
 74   
         }
 75   
     }
 76   
 
 77   
     /**
 78   
      * Returns a simplified node, if possible (usefull in expressions)
 79   
      * 
 80   
      * @param msql_type Specifies which type of processing should be performed
 81   
      *        MobisnapConstants.MSQL_SERVER = 1
 82   
      *        MobisnapConstants.MSQL_TENTATIVE_CLIENT = 2
 83   
      *        MobisnapConstants.MSQL_STABLE_CLIENT = 3
 84   
      *        MobisnapConstants.MSQL_RESERVATION_CLIENT = 4
 85   
      * @param cond True if reservations associated iwth transaction should be 
 86   
      * propagated to the current transaction
 87   
      */
 88  0
     public SimpleNode simplify( int msql_type, boolean cond) {
 89  0
         first = (SimpleNode)first.simplify( msql_type, cond);
 90  0
         if( type > 1 || secondquery || secondprior || firstprior)
 91  0
             return this;
 92  0
         if( type == 0)
 93  0
             return first;
 94  0
         v2 = ((SimpleNode)v2).simplify( msql_type, cond);
 95  0
         try {
 96  0
             return new SimpleNodeValue( value( msql_type, cond));
 97   
         } catch( Exception e) {
 98  0
             return this;
 99   
         }
 100   
     }
 101   
 
 102   
 }
 103