public String toGetSourceString()

in src/main/java/org/apache/commons/ognl/ASTAssign.java [48:107]


    public String toGetSourceString( OgnlContext context, Object target )
    {
        String result = "";

        String first = children[0].toGetSourceString( context, target );
        String second = "";

        if (children[1] instanceof ASTProperty)
        {
            second += "((" + OgnlRuntime.getCompiler( context ).getClassName( target.getClass() ) + ")$2).";
        }

        second += children[1].toGetSourceString( context, target );

        if ( ASTSequence.class.isAssignableFrom( children[1].getClass() ) )
        {
            ASTSequence seq = (ASTSequence) children[1];

            context.setCurrentType( Object.class );

            String core = seq.getCoreExpression();
            if ( core.endsWith( ";" ) )
            {
                core = core.substring( 0, core.lastIndexOf( ";" ) );
            }

            second =
                OgnlRuntime.getCompiler( context ).createLocalReference( context,
                                                                "org.apache.commons.ognl.OgnlOps.returnValue(($w)"
                                                                    + core + ", ($w) " + seq.getLastExpression() + ")",
                                                                Object.class );
        }

        if ( children[1] instanceof NodeType && !(children[1] instanceof ASTProperty)
            && ( (NodeType) children[1] ).getGetterClass() != null && !(children[1] instanceof OrderedReturn))
        {

            second = "new " + ( (NodeType) children[1] ).getGetterClass().getName() + "(" + second + ")";
        }

        if ( OrderedReturn.class.isAssignableFrom( children[0].getClass() )
            && ( (OrderedReturn) children[0] ).getCoreExpression() != null )
        {
            context.setCurrentType( Object.class );

            result = first + second + ")";

            // System.out.println("building ordered ret from child[0] with result of:" + result);

            result =
                OgnlRuntime
                    .getCompiler( context )
                    .createLocalReference( context,
                                           "org.apache.commons.ognl.OgnlOps.returnValue(($w)" + result + ", ($w)"
                                               + ( (OrderedReturn) children[0] ).getLastExpression() + ")",
                                           Object.class );
        }

        return result;
    }