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