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 ASTPlSqlSimpleExpression 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 ASTPlSqlMultiplicativeExpression first; 16 public Vector ors; 17 18 public ASTPlSqlSimpleExpression(int id) { 19 super(id); 20 ors = new Vector(); 21 } 22 23 public ASTPlSqlSimpleExpression( MobisnapSQL p, int i) { 24 super( p, i); 25 id = i; 26 ors = new Vector(); 27 } 28 29 /*** Accept the visitor. **/ 30 public Object jjtAccept(MobisnapSQLVisitor visitor, Object data) { 31 return visitor.visit(this, data); 32 } 33 34 public class term { 35 public byte opType; 36 public ASTPlSqlMultiplicativeExpression expr; 37 38 public term( byte opType, ASTPlSqlMultiplicativeExpression expr) { 39 this.opType = opType; 40 this.expr = expr; 41 } 42 }; 43 44 public void insert( byte opType, ASTPlSqlMultiplicativeExpression expr) { 45 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 * @param cond True if reservations associated iwth transaction should be 57 * propagated to the current transaction 58 */ 59 public Object value( int msql_type, boolean cond) throws Exception { 60 Object val = first.value( msql_type, cond); 61 for( int i = 0; i < ors.size(); i++) { 62 term t = (term)ors.elementAt( i); 63 if( t.opType == OP_PLUS) 64 val = MSQLTypeUtil.add( val, t.expr.value( msql_type, cond)); 65 else if( t.opType == OP_MINUS) 66 val = MSQLTypeUtil.subtract( val, t.expr.value( msql_type, cond)); 67 else 68 val = MSQLTypeUtil.concat( val, t.expr.value( msql_type, cond)); 69 } 70 return val; 71 } 72 73 }

This page was automatically generated by Maven