| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.commons.jexl.parser; |
| 18 |
|
|
| 19 |
|
import org.apache.commons.jexl.JexlContext; |
| 20 |
|
import org.apache.commons.jexl.util.Coercion; |
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
public class ASTLTNode extends SimpleNode |
| 32 |
|
{ |
| 33 |
|
public ASTLTNode(int id) |
| 34 |
|
{ |
| 35 |
0 |
super(id); |
| 36 |
0 |
} |
| 37 |
|
|
| 38 |
|
public ASTLTNode(Parser p, int id) |
| 39 |
|
{ |
| 40 |
60 |
super(p, id); |
| 41 |
60 |
} |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
public Object jjtAccept(ParserVisitor visitor, Object data) |
| 45 |
|
{ |
| 46 |
0 |
return visitor.visit(this, data); |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
public Object value(JexlContext jc) |
| 50 |
|
throws Exception |
| 51 |
|
{ |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
60 |
Object left = ( (SimpleNode) jjtGetChild(0)).value(jc); |
| 57 |
60 |
Object right = ( (SimpleNode) jjtGetChild(1)).value(jc); |
| 58 |
|
|
| 59 |
60 |
if( ( left == right ) || ( left == null ) || ( right == class="keyword">null ) ) |
| 60 |
|
{ |
| 61 |
0 |
return Boolean.FALSE; |
| 62 |
|
} |
| 63 |
60 |
else if( Coercion.isFloatingPoint( left ) || Coercion.isFloatingPoint( right ) ) |
| 64 |
|
{ |
| 65 |
0 |
double leftDouble = Coercion.coerceDouble( left ).class="keyword">doubleValue(); |
| 66 |
0 |
double rightDouble = Coercion.coerceDouble( right ).class="keyword">doubleValue(); |
| 67 |
|
|
| 68 |
0 |
return leftDouble < rightDouble |
| 69 |
|
? Boolean.TRUE |
| 70 |
|
: Boolean.FALSE; |
| 71 |
|
} |
| 72 |
60 |
else if( Coercion.isNumberable( left ) || Coercion.isNumberable( right ) ) |
| 73 |
|
{ |
| 74 |
60 |
long leftLong = Coercion.coerceLong( left ).class="keyword">longValue(); |
| 75 |
60 |
long rightLong = Coercion.coerceLong( right ).class="keyword">longValue(); |
| 76 |
|
|
| 77 |
64 |
return leftLong < rightLong |
| 78 |
1 |
? Boolean.TRUE |
| 79 |
3 |
: Boolean.FALSE; |
| 80 |
|
} |
| 81 |
0 |
else if( left instanceof String || right instanceof String ) |
| 82 |
|
{ |
| 83 |
0 |
String leftString = left.toString(); |
| 84 |
0 |
String rightString = right.toString(); |
| 85 |
|
|
| 86 |
0 |
return leftString.compareTo( rightString ) < 0 |
| 87 |
|
? Boolean.TRUE |
| 88 |
|
: Boolean.FALSE; |
| 89 |
|
} |
| 90 |
0 |
else if( left instanceof Comparable ) |
| 91 |
|
{ |
| 92 |
0 |
return ( (Comparable)left ).compareTo( right ) < 0 |
| 93 |
|
? Boolean.TRUE |
| 94 |
|
: Boolean.FALSE; |
| 95 |
|
} |
| 96 |
0 |
else if( right instanceof Comparable ) |
| 97 |
|
{ |
| 98 |
0 |
return ( (Comparable)right ).compareTo( left ) > 0 |
| 99 |
|
? Boolean.TRUE |
| 100 |
|
: Boolean.FALSE; |
| 101 |
|
} |
| 102 |
|
|
| 103 |
0 |
throw new Exception("Invalid comparison : LT "); |
| 104 |
|
} |
| 105 |
|
} |