public String toGetSourceString()

in src/main/java/org/apache/commons/ognl/ExpressionNode.java [80:134]


    public String toGetSourceString( OgnlContext context, Object target )
    {
        StringBuilder result =
            new StringBuilder(
                ( parent == null || NumericExpression.class.isAssignableFrom( parent.getClass() ) ) ? "" : "(" );

        if ( ( children != null ) && ( children.length > 0 ) )
        {
            for ( int i = 0; i < children.length; ++i )
            {
                if ( i > 0 )
                {
                    result.append( " " ).append( getExpressionOperator( i ) ).append( " " );
                }

                String value = children[i].toGetSourceString( context, target );

                if ( ( children[i] instanceof ASTProperty || children[i] instanceof ASTMethod
                    || children[i] instanceof ASTSequence || children[i] instanceof ASTChain)
                    && value != null && !value.trim().isEmpty() )
                {

                    String pre = null;
                    if (children[i] instanceof ASTMethod)
                    {
                        pre = (String) context.get( "_currentChain" );
                    }

                    if ( pre == null )
                    {
                        pre = "";
                    }

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

                    value =
                        cast + ExpressionCompiler.getRootExpression( children[i], context.getRoot(), context ) + pre
                            + value;
                }

                result.append( value );
            }
        }

        if ( parent != null && !NumericExpression.class.isAssignableFrom( parent.getClass() ) )
        {
            result.append( ")" );
        }

        return result.toString();
    }