|
|||||||||||||||||||
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 | |||||||||||||||
ASTPlSqlSimpleExpression.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 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 | 0 |
public ASTPlSqlSimpleExpression(int id) { |
19 | 0 |
super(id);
|
20 | 0 |
ors = new Vector();
|
21 |
} |
|
22 |
|
|
23 | 0 |
public ASTPlSqlSimpleExpression( 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 ASTPlSqlMultiplicativeExpression expr;
|
|
37 |
|
|
38 | 0 |
public term( byte opType, ASTPlSqlMultiplicativeExpression expr) { |
39 | 0 |
this.opType = opType;
|
40 | 0 |
this.expr = expr;
|
41 |
} |
|
42 |
}; |
|
43 |
|
|
44 | 0 |
public void insert( byte opType, ASTPlSqlMultiplicativeExpression 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 |
* @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 < ors.size(); i++) { |
62 | 0 |
term t = (term)ors.elementAt( i); |
63 | 0 |
if( t.opType == OP_PLUS)
|
64 | 0 |
val = MSQLTypeUtil.add( val, t.expr.value( msql_type, cond)); |
65 | 0 |
else if( t.opType == OP_MINUS) |
66 | 0 |
val = MSQLTypeUtil.subtract( val, t.expr.value( msql_type, cond)); |
67 |
else
|
|
68 | 0 |
val = MSQLTypeUtil.concat( val, t.expr.value( msql_type, cond)); |
69 |
} |
|
70 | 0 |
return val;
|
71 |
} |
|
72 |
|
|
73 |
} |
|
74 |
|
|