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