|
|||||||||||||||||||
| 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 | |||||||||||||||
| ASTSQLUnaryExpression.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/* JJT: 0.2.2 */
|
|
| 2 |
|
|
| 3 |
package mobisnap.mobile_trx;
|
|
| 4 |
|
|
| 5 |
/**
|
|
| 6 |
* Implements unary expression
|
|
| 7 |
*/
|
|
| 8 |
public class ASTSQLUnaryExpression extends mobisnap.mobile_trx.SimpleNode { |
|
| 9 |
public SimpleNode expr;
|
|
| 10 |
public byte sign = 0; // 0 - no sign; 1 - + ; 2 - - |
|
| 11 |
|
|
| 12 | 0 |
public ASTSQLUnaryExpression(int id) { |
| 13 | 0 |
super(id);
|
| 14 |
} |
|
| 15 |
|
|
| 16 | 0 |
public ASTSQLUnaryExpression( MobisnapSQL p, int i) { |
| 17 | 0 |
super( p, i);
|
| 18 | 0 |
id = i; |
| 19 |
} |
|
| 20 |
|
|
| 21 |
/** Accept the visitor. **/
|
|
| 22 | 0 |
public Object jjtAccept(MobisnapSQLVisitor visitor, Object data) {
|
| 23 | 0 |
return visitor.visit(this, data); |
| 24 |
} |
|
| 25 |
|
|
| 26 |
/**
|
|
| 27 |
* Returns the value of the expression
|
|
| 28 |
*
|
|
| 29 |
* @param msql_type Specifies which type of processing should be performed
|
|
| 30 |
* MobisnapConstants.MSQL_SERVER = 1
|
|
| 31 |
* MobisnapConstants.MSQL_TENTATIVE_CLIENT = 2
|
|
| 32 |
* MobisnapConstants.MSQL_STABLE_CLIENT = 3
|
|
| 33 |
* MobisnapConstants.MSQL_RESERVATION_CLIENT = 4
|
|
| 34 |
* MobisnapConstants.MSQL_STATIC = 10
|
|
| 35 |
* @param cond True if reservations associated iwth transaction should be
|
|
| 36 |
* propagated to the current transaction
|
|
| 37 |
*/
|
|
| 38 | 0 |
public Object value( int msql_type, boolean cond) throws Exception { |
| 39 | 0 |
Object val = expr.value( msql_type, cond); |
| 40 | 0 |
if( sign == 0)
|
| 41 | 0 |
return val;
|
| 42 | 0 |
if( sign == 1) {
|
| 43 | 0 |
MSQLTypeUtil.negate( val); // just to test if sign may be assigned
|
| 44 | 0 |
return val;
|
| 45 |
} else
|
|
| 46 | 0 |
return MSQLTypeUtil.negate( val);
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
/**
|
|
| 50 |
* Returns a simplified node, if possible (usefull in expressions)
|
|
| 51 |
*
|
|
| 52 |
* @param msql_type Specifies which type of processing should be performed
|
|
| 53 |
* MobisnapConstants.MSQL_SERVER = 1
|
|
| 54 |
* MobisnapConstants.MSQL_TENTATIVE_CLIENT = 2
|
|
| 55 |
* MobisnapConstants.MSQL_STABLE_CLIENT = 3
|
|
| 56 |
* MobisnapConstants.MSQL_RESERVATION_CLIENT = 4
|
|
| 57 |
* MobisnapConstants.MSQL_STATIC = 10
|
|
| 58 |
* @param cond True if reservations associated iwth transaction should be
|
|
| 59 |
* propagated to the current transaction
|
|
| 60 |
*/
|
|
| 61 | 0 |
public SimpleNode simplify( int msql_type, boolean cond) { |
| 62 | 0 |
expr = (SimpleNode)expr.simplify( msql_type, cond); |
| 63 | 0 |
try {
|
| 64 | 0 |
return new SimpleNodeValue( value( msql_type, cond)); |
| 65 |
} catch( Exception e) {
|
|
| 66 | 0 |
if( sign == 0)
|
| 67 | 0 |
return expr;
|
| 68 | 0 |
return this; |
| 69 |
} |
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
} |
|
| 73 |
|
|
||||||||||