in src/main/java/org/apache/commons/ognl/ASTOr.java [142:198]
public String toSetSourceString( OgnlContext context, Object target )
{
if ( children.length != 2 )
{
throw new UnsupportedCompilationException( "Can only compile boolean expressions with two children." );
}
String pre = (String) context.get( "_currentChain" );
if ( pre == null )
{
pre = "";
}
String result = "";
try
{
children[0].getValue( context, target );
String first =
ExpressionCompiler.getRootExpression( children[0], context.getRoot(), context ) + pre
+ children[0].toGetSourceString( context, target );
if ( !OgnlRuntime.isBoolean( first ) )
{
first = OgnlRuntime.getCompiler( context ).createLocalReference( context, first, Object.class );
}
children[1].getValue( context, target );
String second =
ExpressionCompiler.getRootExpression( children[1], context.getRoot(), context ) + pre
+ children[1].toSetSourceString( context, target );
if ( !OgnlRuntime.isBoolean( second ) )
{
second = OgnlRuntime.getCompiler( context ).createLocalReference( context, second, context.getCurrentType() );
}
result += "org.apache.commons.ognl.OgnlOps.booleanValue(" + first + ")";
result += " ? ";
result += first;
result += " : ";
result += second;
context.setCurrentObject( target );
context.setCurrentType( Boolean.TYPE );
}
catch ( Throwable t )
{
throw OgnlOps.castToRuntime( t );
}
return result;
}