| 1 | |
package org.apache.commons.ognl; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
import org.apache.commons.ognl.enhance.UnsupportedCompilationException; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
public abstract class BooleanExpression |
| 30 | |
extends ExpressionNode |
| 31 | |
implements NodeType |
| 32 | |
{ |
| 33 | |
|
| 34 | |
private static final long serialVersionUID = 8630306635724834872L; |
| 35 | |
|
| 36 | |
protected Class<?> getterClass; |
| 37 | |
|
| 38 | |
public BooleanExpression( int id ) |
| 39 | |
{ |
| 40 | 265 | super( id ); |
| 41 | 265 | } |
| 42 | |
|
| 43 | |
public BooleanExpression( OgnlParser p, int id ) |
| 44 | |
{ |
| 45 | 0 | super( p, id ); |
| 46 | 0 | } |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public Class<?> getGetterClass() |
| 52 | |
{ |
| 53 | 3 | return getterClass; |
| 54 | |
} |
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
public Class<?> getSetterClass() |
| 60 | |
{ |
| 61 | 0 | return null; |
| 62 | |
} |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
@Override |
| 68 | |
public String toGetSourceString( OgnlContext context, Object target ) |
| 69 | |
{ |
| 70 | |
try |
| 71 | |
{ |
| 72 | |
|
| 73 | 18 | Object value = getValueBody( context, target ); |
| 74 | |
|
| 75 | 18 | if ( value != null && Boolean.class.isAssignableFrom( value.getClass() ) ) |
| 76 | |
{ |
| 77 | 18 | getterClass = Boolean.TYPE; |
| 78 | |
} |
| 79 | 0 | else if ( value != null ) |
| 80 | |
{ |
| 81 | 0 | getterClass = value.getClass(); |
| 82 | |
} |
| 83 | |
else |
| 84 | |
{ |
| 85 | 0 | getterClass = Boolean.TYPE; |
| 86 | |
} |
| 87 | |
|
| 88 | 18 | String ret = super.toGetSourceString( context, target ); |
| 89 | |
|
| 90 | 18 | if ( "(false)".equals( ret ) ) |
| 91 | |
{ |
| 92 | 6 | return "false"; |
| 93 | |
} |
| 94 | 12 | else if ( "(true)".equals( ret ) ) |
| 95 | |
{ |
| 96 | 0 | return "true"; |
| 97 | |
} |
| 98 | 12 | return ret; |
| 99 | |
|
| 100 | |
} |
| 101 | 0 | catch ( NullPointerException e ) |
| 102 | |
{ |
| 103 | |
|
| 104 | |
|
| 105 | 0 | e.printStackTrace(); |
| 106 | |
|
| 107 | 0 | throw new UnsupportedCompilationException( "evaluation resulted in null expression." ); |
| 108 | |
} |
| 109 | 0 | catch ( Throwable t ) |
| 110 | |
{ |
| 111 | 0 | throw OgnlOps.castToRuntime( t ); |
| 112 | |
} |
| 113 | |
} |
| 114 | |
} |