commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1184879 - /commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/
Date Sun, 16 Oct 2011 17:41:30 GMT
Author: simonetripodi
Date: Sun Oct 16 17:41:29 2011
New Revision: 1184879

URL: http://svn.apache.org/viewvc?rev=1184879&view=rev
Log:
[OGNL-27] Move toString implementations into visitor pattern. - patch contributed by Daniel
Pitts

Modified:
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTAssign.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTChain.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTConst.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTEval.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTIn.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTInstanceof.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTKeyValue.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTList.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMap.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNegate.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotIn.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProject.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelect.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectFirst.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectLast.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSequence.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticField.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTThisVarRef.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTVarRef.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ExpressionNode.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTAssign.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTAssign.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTAssign.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTAssign.java Sun Oct
16 17:41:29 2011
@@ -48,11 +48,6 @@ class ASTAssign
         return result;
     }
 
-    public String toString()
-    {
-        return _children[0] + " = " + _children[1];
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         String result = "";

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTBitNegate.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTBitNegate.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTBitNegate.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTBitNegate.java Sun
Oct 16 17:41:29 2011
@@ -43,11 +43,6 @@ class ASTBitNegate
         return OgnlOps.bitNegate( _children[0].getValue( context, source ) );
     }
 
-    public String toString()
-    {
-        return "~" + _children[0];
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         String source = _children[0].toGetSourceString( context, target );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTChain.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTChain.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTChain.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTChain.java Sun Oct
16 17:41:29 2011
@@ -277,27 +277,6 @@ public class ASTChain
         return setterClass;
     }
 
-    public String toString()
-    {
-        StringBuilder result = new StringBuilder( "" );
-
-        if ( ( _children != null ) && ( _children.length > 0 ) )
-        {
-            for ( int i = 0; i < _children.length; i++ )
-            {
-                if ( i > 0 )
-                {
-                    if ( !( _children[i] instanceof ASTProperty ) || !( (ASTProperty) _children[i]
).isIndexedAccess() )
-                    {
-                        result.append( "." );
-                    }
-                }
-                result.append( _children[i].toString() );
-            }
-        }
-        return result.toString();
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         String prevChain = (String) context.get( "_currentChain" );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTConst.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTConst.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTConst.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTConst.java Sun Oct
16 17:41:29 2011
@@ -21,9 +21,6 @@ package org.apache.commons.ognl;
 
 import org.apache.commons.ognl.enhance.UnsupportedCompilationException;
 
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
 /**
  * $Id$
  * @author Luke Blanshard (blanshlu@netscape.net)
@@ -89,61 +86,6 @@ public class ASTConst
         return null;
     }
 
-    public String toString()
-    {
-        String result;
-
-        if ( value == null )
-        {
-            result = "null";
-        }
-        else
-        {
-            if ( value instanceof String )
-            {
-                result = '\"' + OgnlOps.getEscapeString( value.toString() ) + '\"';
-            }
-            else
-            {
-                if ( value instanceof Character )
-                {
-                    result = '\'' + OgnlOps.getEscapedChar( ( (Character) value ).charValue()
) + '\'';
-                }
-                else
-                {
-                    result = value.toString();
-
-                    if ( value instanceof Long )
-                    {
-                        result = result + "L";
-                    }
-                    else
-                    {
-                        if ( value instanceof BigDecimal )
-                        {
-                            result = result + "B";
-                        }
-                        else
-                        {
-                            if ( value instanceof BigInteger )
-                            {
-                                result = result + "H";
-                            }
-                            else
-                            {
-                                if ( value instanceof Node )
-                                {
-                                    result = ":[ " + result + " ]";
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return result;
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         if ( value == null && _parent != null && ExpressionNode.class.isInstance(
_parent ) )

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java Sun Oct 16
17:41:29 2011
@@ -54,6 +54,18 @@ public class ASTCtor
         this.className = className;
     }
 
+    /**
+     * Get the class name for this constructor.
+     *
+     * @return the class name.
+     * @since 4.0
+     */
+    String getClassName()
+    {
+        return className;
+    }
+
+
     void setArray( boolean value )
     {
         isArray = value;
@@ -140,39 +152,6 @@ public class ASTCtor
         }
     }
 
-    public String toString()
-    {
-        StringBuilder result = new StringBuilder( "new " ).append( className );
-
-        if ( isArray )
-        {
-            if ( _children[0] instanceof ASTConst )
-            {
-                result.append( "[" ).append( _children[0] ).append( "]" );
-            }
-            else
-            {
-                result.append( "[] " ).append( _children[0] );
-            }
-        }
-        else
-        {
-            result.append( "(" );
-            if ( ( _children != null ) && ( _children.length > 0 ) )
-            {
-                for ( int i = 0; i < _children.length; i++ )
-                {
-                    if ( i > 0 )
-                    {
-                        result.append( ", " );
-                    }
-                    result.append( _children[i] );
-                }
-            }
-            result.append( ")" );
-        }
-        return result.toString();
-    }
 
     public String toGetSourceString( OgnlContext context, Object target )
     {
@@ -389,8 +368,8 @@ public class ASTCtor
     {
         return "";
     }
-    
-    public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data
) 
+
+    public <R,P> R accept(NodeVisitor<? extends R, ? super P> visitor, P data)
     {
         return visitor.visit( this, data );
     }

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTEval.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTEval.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTEval.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTEval.java Sun Oct 16
17:41:29 2011
@@ -79,11 +79,6 @@ class ASTEval
         }
     }
 
-    public String toString()
-    {
-        return "(" + _children[0] + ")(" + _children[1] + ")";
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         throw new UnsupportedCompilationException( "Eval expressions not supported as native
java yet." );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTIn.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTIn.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTIn.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTIn.java Sun Oct 16
17:41:29 2011
@@ -49,11 +49,6 @@ class ASTIn
         return OgnlOps.in( v1, v2 ) ? Boolean.TRUE : Boolean.FALSE;
     }
 
-    public String toString()
-    {
-        return _children[0] + " in " + _children[1];
-    }
-
     public Class getGetterClass()
     {
         return Boolean.TYPE;

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTInstanceof.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTInstanceof.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTInstanceof.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTInstanceof.java Sun
Oct 16 17:41:29 2011
@@ -45,6 +45,10 @@ public class ASTInstanceof
         this.targetType = targetType;
     }
 
+    String getTargetType() {
+        return targetType;
+    }
+
     protected Object getValueBody( OgnlContext context, Object source )
         throws OgnlException
     {
@@ -52,11 +56,6 @@ public class ASTInstanceof
         return OgnlRuntime.isInstance( context, value, targetType ) ? Boolean.TRUE : Boolean.FALSE;
     }
 
-    public String toString()
-    {
-        return _children[0] + " instanceof " + targetType;
-    }
-
     public Class getGetterClass()
     {
         return boolean.class;

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTKeyValue.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTKeyValue.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTKeyValue.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTKeyValue.java Sun Oct
16 17:41:29 2011
@@ -56,11 +56,6 @@ class ASTKeyValue
         return null;
     }
 
-    public String toString()
-    {
-        return getKey() + " -> " + getValue();
-    }
-    
     public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data
) 
     {
         return visitor.visit( this, data );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTList.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTList.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTList.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTList.java Sun Oct 16
17:41:29 2011
@@ -65,21 +65,6 @@ public class ASTList
         return null;
     }
 
-    public String toString()
-    {
-        StringBuilder result = new StringBuilder( "{ " );
-
-        for ( int i = 0; i < jjtGetNumChildren(); ++i )
-        {
-            if ( i > 0 )
-            {
-                result.append( ", " );
-            }
-            result.append( _children[i].toString() );
-        }
-        return result.append( " }" ).toString();
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         String result = "";

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMap.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMap.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMap.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMap.java Sun Oct 16
17:41:29 2011
@@ -65,6 +65,17 @@ class ASTMap
         className = value;
     }
 
+    /**
+     * Get the class name for this map.
+     *
+     * @return the class name.
+     * @since 4.0
+     */
+    String getClassName()
+    {
+        return className;
+    }
+
     protected Object getValueBody( OgnlContext context, Object source )
         throws OgnlException
     {
@@ -106,29 +117,6 @@ class ASTMap
         return answer;
     }
 
-    public String toString()
-    {
-        StringBuilder result = new StringBuilder( "#" );
-
-        if ( className != null )
-        {
-            result.append( "@" ).append( className ).append( "@" );
-        }
-
-        result.append( "{ " );
-        for ( int i = 0; i < jjtGetNumChildren(); ++i )
-        {
-            ASTKeyValue kv = (ASTKeyValue) _children[i];
-
-            if ( i > 0 )
-            {
-                result.append( ", " );
-            }
-            result.append( kv.getKey() ).append( " : " ).append( kv.getValue() );
-        }
-        return result.append( " }" ).toString();
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         throw new UnsupportedCompilationException( "Map expressions not supported as native
java yet." );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java Sun Oct
16 17:41:29 2011
@@ -152,30 +152,6 @@ public class ASTMethod
     {
         return getterClass;
     }
-
-    public String toString()
-    {
-        StringBuilder result = new StringBuilder( methodName );
-
-        result.append( "(" );
-        if ( ( _children != null ) && ( _children.length > 0 ) )
-        {
-
-            for ( int i = 0; i < _children.length; i++ )
-            {
-                if ( i > 0 )
-                {
-                    result.append( ", " );
-                }
-
-                result.append( _children[i] );
-            }
-        }
-
-        result.append( ")" );
-        return result.toString();
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         /*

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNegate.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNegate.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNegate.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNegate.java Sun Oct
16 17:41:29 2011
@@ -43,11 +43,6 @@ class ASTNegate
         return OgnlOps.negate( _children[0].getValue( context, source ) );
     }
 
-    public String toString()
-    {
-        return "-" + _children[0];
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         String source = _children[0].toGetSourceString( context, target );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotIn.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotIn.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotIn.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotIn.java Sun Oct
16 17:41:29 2011
@@ -48,11 +48,6 @@ class ASTNotIn
         return OgnlOps.in( v1, v2 ) ? Boolean.FALSE : Boolean.TRUE;
     }
 
-    public String toString()
-    {
-        return _children[0] + " not in " + _children[1];
-    }
-
     public Class getGetterClass()
     {
         return Boolean.TYPE;

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProject.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProject.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProject.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProject.java Sun Oct
16 17:41:29 2011
@@ -61,11 +61,6 @@ class ASTProject
         return answer;
     }
 
-    public String toString()
-    {
-        return "{ " + _children[0] + " }";
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         throw new UnsupportedCompilationException( "Projection expressions not supported
as native java yet." );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java Sun Oct
16 17:41:29 2011
@@ -139,21 +139,6 @@ public class ASTProperty
         return _setterClass;
     }
 
-    public String toString()
-    {
-        String result;
-
-        if ( isIndexedAccess() )
-        {
-            result = "[" + _children[0] + "]";
-        }
-        else
-        {
-            result = ( (ASTConst) _children[0] ).getValue().toString();
-        }
-        return result;
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         if ( context.getCurrentObject() == null )

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTRootVarRef.java Sun
Oct 16 17:41:29 2011
@@ -51,11 +51,6 @@ public class ASTRootVarRef
         context.setRoot( value );
     }
 
-    public String toString()
-    {
-        return "#root";
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         if ( target != null )

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelect.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelect.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelect.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelect.java Sun Oct
16 17:41:29 2011
@@ -63,11 +63,6 @@ class ASTSelect
         return answer;
     }
 
-    public String toString()
-    {
-        return "{? " + _children[0] + " }";
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         throw new UnsupportedCompilationException( "Eval expressions not supported as native
java yet." );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectFirst.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectFirst.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectFirst.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectFirst.java Sun
Oct 16 17:41:29 2011
@@ -63,11 +63,6 @@ class ASTSelectFirst
         return answer;
     }
 
-    public String toString()
-    {
-        return "{^ " + _children[0] + " }";
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         throw new UnsupportedCompilationException( "Eval expressions not supported as native
java yet." );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectLast.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectLast.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectLast.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSelectLast.java Sun
Oct 16 17:41:29 2011
@@ -63,11 +63,6 @@ class ASTSelectLast
         return answer;
     }
 
-    public String toString()
-    {
-        return "{$ " + _children[0] + " }";
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         throw new UnsupportedCompilationException( "Eval expressions not supported as native
java yet." );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSequence.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSequence.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSequence.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTSequence.java Sun Oct
16 17:41:29 2011
@@ -95,21 +95,6 @@ public class ASTSequence
         return _coreExpression;
     }
 
-    public String toString()
-    {
-        StringBuilder result = new StringBuilder( "" );
-
-        for ( int i = 0; i < _children.length; ++i )
-        {
-            if ( i > 0 )
-            {
-                result.append( ", " );
-            }
-            result.append( _children[i] );
-        }
-        return result.toString();
-    }
-
     public String toSetSourceString( OgnlContext context, Object target )
     {
         return "";

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticField.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticField.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticField.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticField.java Sun
Oct 16 17:41:29 2011
@@ -165,11 +165,6 @@ public class ASTStaticField
         return _getterClass;
     }
 
-    public String toString()
-    {
-        return "@" + className + "@" + fieldName;
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         try
@@ -218,4 +213,26 @@ public class ASTStaticField
     {
         return visitor.visit( this, data );
     }
+
+    /**
+     * Get the field name for this field.
+     *
+     * @return the field name.
+     * @since 4.0
+     */
+    String getFieldName()
+    {
+        return fieldName;
+    }
+
+    /**
+     * Get the class name for this field.
+     *
+     * @return the class name.
+     * @since 4.0
+     */
+    String getClassName()
+    {
+        return className;
+    }
 }

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java Sun
Oct 16 17:41:29 2011
@@ -85,26 +85,6 @@ public class ASTStaticMethod
         return _getterClass;
     }
 
-    public String toString()
-    {
-        StringBuilder result = new StringBuilder( "@" ).append( _className ).append( "@"
).append( _methodName );
-
-        result.append( "(" );
-        if ( ( _children != null ) && ( _children.length > 0 ) )
-        {
-            for ( int i = 0; i < _children.length; i++ )
-            {
-                if ( i > 0 )
-                {
-                    result.append( ", " );
-                }
-                result.append( _children[i] );
-            }
-        }
-        result.append( ")" );
-        return result.toString();
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         String result = _className + "#" + _methodName + "(";
@@ -268,4 +248,26 @@ public class ASTStaticMethod
     {
         return visitor.visit( this, data );
     }
+
+    /**
+     * Get the class name for this method.
+     *
+     * @return the class name.
+     * @since 4.0
+     */
+    public String getClassName()
+    {
+        return _className;
+    }
+
+    /**
+     * Get the method name for this method.
+     *
+     * @return the method name.
+     * @since 4.0
+     */
+    public String getMethodName()
+    {
+        return _methodName;
+    }
 }

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTThisVarRef.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTThisVarRef.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTThisVarRef.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTThisVarRef.java Sun
Oct 16 17:41:29 2011
@@ -52,11 +52,6 @@ public class ASTThisVarRef
         context.setCurrentObject( value );
     }
 
-    public String toString()
-    {
-        return "#this";
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         throw new UnsupportedCompilationException( "Unable to compile this references." );

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTVarRef.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTVarRef.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTVarRef.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTVarRef.java Sun Oct
16 17:41:29 2011
@@ -54,6 +54,16 @@ public class ASTVarRef
     {
         this._name = name;
     }
+    /**
+     * Get the variable name.
+     *
+     * @return the variable name.
+     * @since 4.0
+     */
+    String getName()
+    {
+        return _name;
+    }
 
     protected Object getValueBody( OgnlContext context, Object source )
         throws OgnlException
@@ -87,11 +97,6 @@ public class ASTVarRef
         return _last;
     }
 
-    public String toString()
-    {
-        return "#" + _name;
-    }
-
     public String toGetSourceString( OgnlContext context, Object target )
     {
         Object value = context.get( _name );
@@ -134,8 +139,8 @@ public class ASTVarRef
     {
         return toGetSourceString( context, target );
     }
-    
-    public <R, P> R accept( NodeVisitor<? extends R, ? super P> visitor, P data
) 
+
+    public <R,P> R accept(NodeVisitor<? extends R, ? super P> visitor, P data)
     {
         return visitor.visit( this, data );
     }

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ExpressionNode.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ExpressionNode.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ExpressionNode.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ExpressionNode.java Sun
Oct 16 17:41:29 2011
@@ -81,29 +81,6 @@ public abstract class ExpressionNode
     }
 
     @Override
-    public String toString()
-    {
-        StringBuilder result = new StringBuilder( _parent == null ? "" : "(" );
-
-        if ( ( _children != null ) && ( _children.length > 0 ) )
-        {
-            for ( int i = 0; i < _children.length; ++i )
-            {
-                if ( i > 0 )
-                {
-                    result.append( " " ).append( getExpressionOperator( i ) ).append( " "
);
-                }
-                result.append( _children[i].toString() );
-            }
-        }
-        if ( _parent != null )
-        {
-            result.append( ')' );
-        }
-        return result.toString();
-    }
-
-    @Override
     public String toGetSourceString( OgnlContext context, Object target )
     {
         StringBuilder result =

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java?rev=1184879&r1=1184878&r2=1184879&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java Sun Oct
16 17:41:29 2011
@@ -113,7 +113,7 @@ public abstract class SimpleNode
     @Override
     public String toString()
     {
-        return OgnlParserTreeConstants.jjtNodeName[_id];
+        return accept( ToStringVisitor.INSTANCE, new StringBuilder()).toString();
     }
 
     // OGNL additions



Mime
View raw message