public static String getChildSource()

in src/main/java/org/apache/commons/ognl/OgnlRuntime.java [2046:2114]


    public static String getChildSource( OgnlContext context, Object target, Node child, boolean forceConversion )
        throws OgnlException
    {
        String pre = (String) context.get( "_currentChain" );
        if ( pre == null )
        {
            pre = "";
        }

        try
        {
            child.getValue( context, target );
        }
        catch ( NullPointerException e )
        {
            // ignore
        }
        catch ( ArithmeticException e )
        {
            context.setCurrentType( int.class );
            return "0";
        }
        catch ( Throwable t )
        {
            throw OgnlOps.castToRuntime( t );
        }

        String source;

        try
        {
            source = child.toGetSourceString( context, target );
        }
        catch ( Throwable t )
        {
            throw OgnlOps.castToRuntime( t );
        }

        // handle root / method expressions that may not have proper root java source access

        if ( !(child instanceof ASTConst) && ( target == null || context.getRoot() != target ) )
        {
            source = pre + source;
        }

        if ( context.getRoot() != null )
        {
            source = ExpressionCompiler.getRootExpression( child, context.getRoot(), context ) + source;
            context.setCurrentAccessor( context.getRoot().getClass() );
        }

        if (child instanceof ASTChain)
        {
            String cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
            if ( cast == null )
            {
                cast = "";
            }

            source = cast + source;
        }

        if ( source == null || source.trim().length() < 1 )
        {
            source = "null";
        }

        return source;
    }