| 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 ASTGTNode extends SimpleNode |
| 31 |
|
{ |
| 32 |
|
public ASTGTNode( int id ) |
| 33 |
|
{ |
| 34 |
0 |
super( id ); |
| 35 |
0 |
} |
| 36 |
|
|
| 37 |
|
public ASTGTNode( Parser p, int id ) |
| 38 |
|
{ |
| 39 |
60 |
super( p, id ); |
| 40 |
60 |
} |
| 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 |
60 |
Object left = ( (SimpleNode)jjtGetChild( 0 ) ).value( jc ); |
| 56 |
60 |
Object right = ( (SimpleNode)jjtGetChild( 1 ) ).value( jc ); |
| 57 |
|
|
| 58 |
60 |
if( ( left == right ) || ( left == null ) || ( right == class="keyword">null ) ) |
| 59 |
|
{ |
| 60 |
0 |
return Boolean.FALSE; |
| 61 |
|
} |
| 62 |
60 |
else if( Coercion.isFloatingPoint( left ) || Coercion.isFloatingPoint( right ) ) |
| 63 |
|
{ |
| 64 |
0 |
double leftDouble = Coercion.coerceDouble( left ).class="keyword">doubleValue(); |
| 65 |
0 |
double rightDouble = Coercion.coerceDouble( right ).class="keyword">doubleValue(); |
| 66 |
|
|
| 67 |
0 |
return leftDouble > rightDouble |
| 68 |
|
? Boolean.TRUE |
| 69 |
|
: Boolean.FALSE; |
| 70 |
|
} |
| 71 |
60 |
else if( Coercion.isNumberable( left ) || Coercion.isNumberable( right ) ) |
| 72 |
|
{ |
| 73 |
60 |
long leftLong = Coercion.coerceLong( left ).class="keyword">longValue(); |
| 74 |
60 |
long rightLong = Coercion.coerceLong( right ).class="keyword">longValue(); |
| 75 |
|
|
| 76 |
64 |
return leftLong > rightLong |
| 77 |
4 |
? Boolean.TRUE |
| 78 |
|
: Boolean.FALSE; |
| 79 |
|
} |
| 80 |
0 |
else if( left instanceof String || right instanceof String ) |
| 81 |
|
{ |
| 82 |
0 |
String leftString = left.toString(); |
| 83 |
0 |
String rightString = right.toString(); |
| 84 |
|
|
| 85 |
0 |
return leftString.compareTo( rightString ) > 0 |
| 86 |
|
? Boolean.TRUE |
| 87 |
|
: Boolean.FALSE; |
| 88 |
|
} |
| 89 |
0 |
else if( left instanceof Comparable ) |
| 90 |
|
{ |
| 91 |
0 |
return ( (Comparable)left ).compareTo( right ) > 0 |
| 92 |
|
? Boolean.TRUE |
| 93 |
|
: Boolean.FALSE; |
| 94 |
|
} |
| 95 |
0 |
else if( right instanceof Comparable ) |
| 96 |
|
{ |
| 97 |
0 |
return ( (Comparable)right ).compareTo( left ) < 0 |
| 98 |
|
? Boolean.TRUE |
| 99 |
|
: Boolean.FALSE; |
| 100 |
|
} |
| 101 |
|
|
| 102 |
0 |
throw new Exception( "Invalid comparison : GT " ); |
| 103 |
|
} |
| 104 |
|
} |