in src/main/java/org/apache/commons/ognl/enhance/ExpressionCompiler.java [209:242]
public String castExpression( OgnlContext context, Node expression, String body )
{
//TODO: ok - so this looks really f-ed up ...and it is ..eh if you can do it better I'm all for it :)
if ( context.getCurrentAccessor() == null || context.getPreviousType() == null
|| context.getCurrentAccessor().isAssignableFrom( context.getPreviousType() ) || (
context.getCurrentType() != null && context.getCurrentObject() != null
&& context.getCurrentType().isAssignableFrom( context.getCurrentObject().getClass() )
&& context.getCurrentAccessor().isAssignableFrom( context.getPreviousType() ) ) || body == null
|| body.trim().length() < 1 || ( context.getCurrentType() != null && context.getCurrentType().isArray() && (
context.getPreviousType() == null || context.getPreviousType() != Object.class ) )
|| expression instanceof ASTOr || expression instanceof ASTAnd
|| expression instanceof ASTRootVarRef || context.getCurrentAccessor() == Class.class || (
context.get( ExpressionCompiler.PRE_CAST ) != null && ( (String) context.get(
ExpressionCompiler.PRE_CAST ) ).startsWith( "new" ) ) || expression instanceof ASTStaticField
|| expression instanceof ASTStaticMethod || ( expression instanceof OrderedReturn
&& ( (OrderedReturn) expression ).getLastExpression() != null ) )
{
return body;
}
/*
* System.out.println("castExpression() with expression " + expression + " expr class: " + expression.getClass()
* + " currentType is: " + context.getCurrentType() + " previousType: " + context.getPreviousType() +
* "\n current Accessor: " + context.getCurrentAccessor() + " previous Accessor: " +
* context.getPreviousAccessor() + " current object " + context.getCurrentObject());
*/
ExpressionCompiler.addCastString( context,
"((" + ExpressionCompiler.getCastString( context.getCurrentAccessor() )
+ ")" );
return ")" + body;
}