You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/05/14 15:18:36 UTC

svn commit: r1103095 [3/24] - in /incubator/ognl/trunk/src: main/java/org/apache/commons/ognl/ main/java/org/apache/commons/ognl/enhance/ main/java/org/apache/commons/ognl/internal/ test/java/org/apache/commons/ognl/ test/java/org/apache/commons/ognl/t...

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTList.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTList.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTList.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTList.java Sat May 14 13:18:29 2011
@@ -29,24 +29,26 @@ import java.util.List;
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-public class ASTList extends SimpleNode implements NodeType
+public class ASTList
+    extends SimpleNode
+    implements NodeType
 {
-    public ASTList(int id)
+    public ASTList( int id )
     {
-        super(id);
+        super( id );
     }
 
-    public ASTList(OgnlParser p, int id)
+    public ASTList( OgnlParser p, int id )
     {
-        super(p, id);
+        super( p, id );
     }
 
-    protected Object getValueBody(OgnlContext context, Object source)
-            throws OgnlException
+    protected Object getValueBody( OgnlContext context, Object source )
+        throws OgnlException
     {
-        List answer = new ArrayList(jjtGetNumChildren());
-        for(int i = 0; i < jjtGetNumChildren(); ++i)
-            answer.add(_children[i].getValue(context, source));
+        List answer = new ArrayList( jjtGetNumChildren() );
+        for ( int i = 0; i < jjtGetNumChildren(); ++i )
+            answer.add( _children[i].getValue( context, source ) );
         return answer;
     }
 
@@ -62,34 +64,36 @@ public class ASTList extends SimpleNode 
 
     public String toString()
     {
-        StringBuilder result = new StringBuilder("{ ");
+        StringBuilder result = new StringBuilder( "{ " );
 
-        for(int i = 0; i < jjtGetNumChildren(); ++i) {
-            if (i > 0) {
-                result.append(", ");
+        for ( int i = 0; i < jjtGetNumChildren(); ++i )
+        {
+            if ( i > 0 )
+            {
+                result.append( ", " );
             }
-            result.append(_children[i].toString());
+            result.append( _children[i].toString() );
         }
-        return result.append(" }").toString();
+        return result.append( " }" ).toString();
     }
 
-    public String toGetSourceString(OgnlContext context, Object target)
+    public String toGetSourceString( OgnlContext context, Object target )
     {
         String result = "";
         boolean array = false;
 
-        if (_parent != null && ASTCtor.class.isInstance(_parent)
-            && ((ASTCtor)_parent).isArray()) {
+        if ( _parent != null && ASTCtor.class.isInstance( _parent ) && ( (ASTCtor) _parent ).isArray() )
+        {
 
             array = true;
         }
 
-        context.setCurrentType(List.class);
-        context.setCurrentAccessor(List.class);
+        context.setCurrentType( List.class );
+        context.setCurrentAccessor( List.class );
 
-        if (!array)
+        if ( !array )
         {
-            if (jjtGetNumChildren() < 1)
+            if ( jjtGetNumChildren() < 1 )
                 return "java.util.Arrays.asList( new Object[0])";
 
             result += "java.util.Arrays.asList( new Object[] ";
@@ -97,111 +101,138 @@ public class ASTList extends SimpleNode 
 
         result += "{ ";
 
-        try {
+        try
+        {
 
-            for(int i = 0; i < jjtGetNumChildren(); ++i) {
-                if (i > 0) {
+            for ( int i = 0; i < jjtGetNumChildren(); ++i )
+            {
+                if ( i > 0 )
+                {
                     result = result + ", ";
                 }
 
                 Class prevType = context.getCurrentType();
 
-                Object objValue = _children[i].getValue(context, context.getRoot());
-                String value = _children[i].toGetSourceString(context, target);
+                Object objValue = _children[i].getValue( context, context.getRoot() );
+                String value = _children[i].toGetSourceString( context, target );
 
                 // to undo type setting of constants when used as method parameters
-                if (ASTConst.class.isInstance(_children[i])) {
+                if ( ASTConst.class.isInstance( _children[i] ) )
+                {
 
-                    context.setCurrentType(prevType);
+                    context.setCurrentType( prevType );
                 }
 
-                value = ExpressionCompiler.getRootExpression(_children[i], target, context) + value;
+                value = ExpressionCompiler.getRootExpression( _children[i], target, context ) + value;
 
                 String cast = "";
-                if (ExpressionCompiler.shouldCast(_children[i])) {
+                if ( ExpressionCompiler.shouldCast( _children[i] ) )
+                {
 
-                    cast = (String)context.remove(ExpressionCompiler.PRE_CAST);
+                    cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
                 }
-                if (cast == null)
+                if ( cast == null )
                     cast = "";
 
-                if (!ASTConst.class.isInstance(_children[i]))
+                if ( !ASTConst.class.isInstance( _children[i] ) )
                     value = cast + value;
 
-                Class ctorClass = (Class)context.get("_ctorClass");
-                if (array && ctorClass != null && !ctorClass.isPrimitive()) {
+                Class ctorClass = (Class) context.get( "_ctorClass" );
+                if ( array && ctorClass != null && !ctorClass.isPrimitive() )
+                {
 
                     Class valueClass = value != null ? value.getClass() : null;
-                    if (NodeType.class.isAssignableFrom(_children[i].getClass()))
-                        valueClass = ((NodeType)_children[i]).getGetterClass();
+                    if ( NodeType.class.isAssignableFrom( _children[i].getClass() ) )
+                        valueClass = ( (NodeType) _children[i] ).getGetterClass();
+
+                    if ( valueClass != null && ctorClass.isArray() )
+                    {
 
-                    if (valueClass != null && ctorClass.isArray()) {
+                        value =
+                            OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                            "("
+                                                                                + ExpressionCompiler.getCastString( ctorClass )
+                                                                                + ")org.apache.commons.ognl.OgnlOps.toArray("
+                                                                                + value
+                                                                                + ", "
+                                                                                + ctorClass.getComponentType().getName()
+                                                                                + ".class, true)", ctorClass );
 
-                        value = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                               "(" + ExpressionCompiler.getCastString(ctorClass)
-                                                                               + ")org.apache.commons.ognl.OgnlOps.toArray(" + value + ", " + ctorClass.getComponentType().getName()
-                                                                               + ".class, true)",
-                                                                               ctorClass
-                        );
-
-                    } else  if (ctorClass.isPrimitive()) {
-
-                        Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(ctorClass);
-
-                        value = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                               "((" + wrapClass.getName()
-                                                                               + ")org.apache.commons.ognl.OgnlOps.convertValue(" + value + ","
-                                                                               + wrapClass.getName() + ".class, true))."
-                                                                               + OgnlRuntime.getNumericValueGetter(wrapClass),
-                                                                               ctorClass
-                        );
-
-                    } else if (ctorClass != Object.class) {
-
-                        value = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                               "(" + ctorClass.getName() + ")org.apache.commons.ognl.OgnlOps.convertValue(" + value + "," + ctorClass.getName() + ".class)",
-                                                                               ctorClass
-                        );
-
-                    } else if ((NodeType.class.isInstance(_children[i])
-                                && ((NodeType)_children[i]).getGetterClass() != null
-                                && Number.class.isAssignableFrom(((NodeType)_children[i]).getGetterClass()))
-                               || valueClass.isPrimitive()) {
+                    }
+                    else if ( ctorClass.isPrimitive() )
+                    {
+
+                        Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( ctorClass );
+
+                        value =
+                            OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                            "(("
+                                                                                + wrapClass.getName()
+                                                                                + ")org.apache.commons.ognl.OgnlOps.convertValue("
+                                                                                + value
+                                                                                + ","
+                                                                                + wrapClass.getName()
+                                                                                + ".class, true))."
+                                                                                + OgnlRuntime.getNumericValueGetter( wrapClass ),
+                                                                            ctorClass );
+
+                    }
+                    else if ( ctorClass != Object.class )
+                    {
+
+                        value =
+                            OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                            "("
+                                                                                + ctorClass.getName()
+                                                                                + ")org.apache.commons.ognl.OgnlOps.convertValue("
+                                                                                + value + "," + ctorClass.getName()
+                                                                                + ".class)", ctorClass );
+
+                    }
+                    else if ( ( NodeType.class.isInstance( _children[i] )
+                        && ( (NodeType) _children[i] ).getGetterClass() != null && Number.class.isAssignableFrom( ( (NodeType) _children[i] ).getGetterClass() ) )
+                        || valueClass.isPrimitive() )
+                    {
 
                         value = " ($w) (" + value + ")";
-                    } else if (valueClass.isPrimitive()) {
+                    }
+                    else if ( valueClass.isPrimitive() )
+                    {
                         value = "($w) (" + value + ")";
                     }
 
-                } else if (ctorClass == null || !ctorClass.isPrimitive()) {
+                }
+                else if ( ctorClass == null || !ctorClass.isPrimitive() )
+                {
 
                     value = " ($w) (" + value + ")";
                 }
 
-                if (objValue == null || value.length() <= 0)
+                if ( objValue == null || value.length() <= 0 )
                     value = "null";
 
                 result += value;
             }
 
-        } catch (Throwable t)
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
 
-        context.setCurrentType(List.class);
-        context.setCurrentAccessor(List.class);
+        context.setCurrentType( List.class );
+        context.setCurrentAccessor( List.class );
 
         result += "}";
 
-        if (!array)
+        if ( !array )
             result += ")";
 
         return result;
     }
 
-    public String toSetSourceString(OgnlContext context, Object target)
+    public String toSetSourceString( OgnlContext context, Object target )
     {
-        throw new UnsupportedCompilationException("Can't generate setter for ASTList.");
+        throw new UnsupportedCompilationException( "Can't generate setter for ASTList." );
     }
 }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMap.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMap.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMap.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMap.java Sat May 14 13:18:29 2011
@@ -28,94 +28,113 @@ import java.util.Map;
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-class ASTMap extends SimpleNode
+class ASTMap
+    extends SimpleNode
 {
 
     private static Class DEFAULT_MAP_CLASS;
+
     private String className;
 
-    static {
+    static
+    {
         /* Try to get LinkedHashMap; if older JDK than 1.4 use HashMap */
-        try {
-            DEFAULT_MAP_CLASS = Class.forName("java.util.LinkedHashMap");
-        } catch (ClassNotFoundException ex) {
+        try
+        {
+            DEFAULT_MAP_CLASS = Class.forName( "java.util.LinkedHashMap" );
+        }
+        catch ( ClassNotFoundException ex )
+        {
             DEFAULT_MAP_CLASS = HashMap.class;
         }
     }
-    
-    public ASTMap(int id)
+
+    public ASTMap( int id )
     {
-        super(id);
+        super( id );
     }
 
-    public ASTMap(OgnlParser p, int id)
+    public ASTMap( OgnlParser p, int id )
     {
-        super(p, id);
+        super( p, id );
     }
 
-    protected void setClassName(String value)
+    protected void setClassName( String value )
     {
         className = value;
     }
 
-    protected Object getValueBody(OgnlContext context, Object source)
+    protected Object getValueBody( OgnlContext context, Object source )
         throws OgnlException
     {
         Map answer;
-        
-        if (className == null) {
-            try {
+
+        if ( className == null )
+        {
+            try
+            {
                 answer = (Map) DEFAULT_MAP_CLASS.newInstance();
-            } catch (Exception ex) {
+            }
+            catch ( Exception ex )
+            {
                 /* This should never happen */
-                throw new OgnlException("Default Map class '" + DEFAULT_MAP_CLASS.getName() + "' instantiation error",
-                        ex);
+                throw new OgnlException( "Default Map class '" + DEFAULT_MAP_CLASS.getName() + "' instantiation error",
+                                         ex );
+            }
+        }
+        else
+        {
+            try
+            {
+                answer = (Map) OgnlRuntime.classForName( context, className ).newInstance();
             }
-        } else {
-            try {
-                answer = (Map) OgnlRuntime.classForName(context, className).newInstance();
-            } catch (Exception ex) {
-                throw new OgnlException("Map implementor '" + className + "' not found", ex);
+            catch ( Exception ex )
+            {
+                throw new OgnlException( "Map implementor '" + className + "' not found", ex );
             }
         }
-        
-        for(int i = 0; i < jjtGetNumChildren(); ++i) {
+
+        for ( int i = 0; i < jjtGetNumChildren(); ++i )
+        {
             ASTKeyValue kv = (ASTKeyValue) _children[i];
             Node k = kv.getKey(), v = kv.getValue();
-            
-            answer.put(k.getValue(context, source), (v == null) ? null : v.getValue(context, source));
+
+            answer.put( k.getValue( context, source ), ( v == null ) ? null : v.getValue( context, source ) );
         }
-        
+
         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) {
+        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(", ");
+            if ( i > 0 )
+            {
+                result.append( ", " );
             }
-            result.append(kv.getKey()).append(" : ").append(kv.getValue());
+            result.append( kv.getKey() ).append( " : " ).append( kv.getValue() );
         }
-        return result.append(" }").toString();
+        return result.append( " }" ).toString();
     }
-    
-    public String toGetSourceString(OgnlContext context, Object target)
+
+    public String toGetSourceString( OgnlContext context, Object target )
     {
-        throw new UnsupportedCompilationException("Map expressions not supported as native java yet.");
+        throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
     }
-    
-    public String toSetSourceString(OgnlContext context, Object target)
+
+    public String toSetSourceString( OgnlContext context, Object target )
     {
-        throw new UnsupportedCompilationException("Map expressions not supported as native java yet.");
+        throw new UnsupportedCompilationException( "Map expressions not supported as native java yet." );
     }
 }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java Sat May 14 13:18:29 2011
@@ -59,7 +59,9 @@ import java.lang.reflect.Method;
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-public class ASTMethod extends SimpleNode implements OrderedReturn, NodeType
+public class ASTMethod
+    extends SimpleNode
+    implements OrderedReturn, NodeType
 {
 
     private String _methodName;
@@ -70,18 +72,18 @@ public class ASTMethod extends SimpleNod
 
     private Class _getterClass;
 
-    public ASTMethod(int id)
+    public ASTMethod( int id )
     {
-        super(id);
+        super( id );
     }
 
-    public ASTMethod(OgnlParser p, int id)
+    public ASTMethod( OgnlParser p, int id )
     {
-        super(p, id);
+        super( p, id );
     }
 
     /** Called from parser action. */
-    public void setMethodName(String methodName)
+    public void setMethodName( String methodName )
     {
         _methodName = methodName;
     }
@@ -94,30 +96,34 @@ public class ASTMethod extends SimpleNod
         return _methodName;
     }
 
-    protected Object getValueBody(OgnlContext context, Object source)
-            throws OgnlException
+    protected Object getValueBody( OgnlContext context, Object source )
+        throws OgnlException
     {
-        Object[] args = OgnlRuntime.getObjectArrayPool().create(jjtGetNumChildren());
+        Object[] args = OgnlRuntime.getObjectArrayPool().create( jjtGetNumChildren() );
 
-        try {
+        try
+        {
             Object result, root = context.getRoot();
 
-            for(int i = 0, icount = args.length; i < icount; ++i) {
-                args[i] = _children[i].getValue(context, root);
+            for ( int i = 0, icount = args.length; i < icount; ++i )
+            {
+                args[i] = _children[i].getValue( context, root );
             }
 
-            result = OgnlRuntime.callMethod(context, source, _methodName, args);
+            result = OgnlRuntime.callMethod( context, source, _methodName, args );
 
-            if (result == null)
+            if ( result == null )
             {
-                NullHandler nh = OgnlRuntime.getNullHandler(OgnlRuntime.getTargetClass(source));
-                result = nh.nullMethodResult(context, source, _methodName, args);
+                NullHandler nh = OgnlRuntime.getNullHandler( OgnlRuntime.getTargetClass( source ) );
+                result = nh.nullMethodResult( context, source, _methodName, args );
             }
 
             return result;
 
-        } finally {
-            OgnlRuntime.getObjectArrayPool().recycle(args);
+        }
+        finally
+        {
+            OgnlRuntime.getObjectArrayPool().recycle( args );
         }
     }
 
@@ -143,162 +149,200 @@ public class ASTMethod extends SimpleNod
 
     public String toString()
     {
-        StringBuilder result = new StringBuilder(_methodName);
+        StringBuilder result = new StringBuilder( _methodName );
 
-        result.append("(");
-        if ((_children != null) && (_children.length > 0)) {
+        result.append( "(" );
+        if ( ( _children != null ) && ( _children.length > 0 ) )
+        {
 
-            for(int i = 0; i < _children.length; i++) {
-                if (i > 0) {
-                    result.append(", ");
+            for ( int i = 0; i < _children.length; i++ )
+            {
+                if ( i > 0 )
+                {
+                    result.append( ", " );
                 }
 
-                result.append(_children[i]);
+                result.append( _children[i] );
             }
         }
 
-        result.append(")");
+        result.append( ")" );
         return result.toString();
     }
 
-    public String toGetSourceString(OgnlContext context, Object target)
+    public String toGetSourceString( OgnlContext context, Object target )
     {
-        /*  System.out.println("methodName is " + _methodName + " for target " + target + " target class: " + (target != null ? target.getClass() : null)
-  + " current type: " + context.getCurrentType());*/
-        if (target == null)
-            throw new UnsupportedCompilationException("Target object is null.");
+        /*
+         * System.out.println("methodName is " + _methodName + " for target " + target + " target class: " + (target !=
+         * null ? target.getClass() : null) + " current type: " + context.getCurrentType());
+         */
+        if ( target == null )
+            throw new UnsupportedCompilationException( "Target object is null." );
 
         String post = "";
         String result = null;
         Method m = null;
 
-        try {
-
-            m = OgnlRuntime.getMethod(context, context.getCurrentType() != null ? context.getCurrentType() : target.getClass(), _methodName, _children, false);
-            if (m == null)
-                m = OgnlRuntime.getReadMethod(target.getClass(), _methodName, _children != null ? _children.length : -1);
+        try
+        {
 
-            if (m == null) {
-                m = OgnlRuntime.getWriteMethod(target.getClass(), _methodName, _children != null ? _children.length : -1);
+            m =
+                OgnlRuntime.getMethod( context,
+                                       context.getCurrentType() != null ? context.getCurrentType() : target.getClass(),
+                                       _methodName, _children, false );
+            if ( m == null )
+                m =
+                    OgnlRuntime.getReadMethod( target.getClass(), _methodName, _children != null ? _children.length
+                                    : -1 );
 
-                if (m != null) {
+            if ( m == null )
+            {
+                m =
+                    OgnlRuntime.getWriteMethod( target.getClass(), _methodName, _children != null ? _children.length
+                                    : -1 );
 
-                    context.setCurrentType(m.getReturnType());
-                    context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass()));
+                if ( m != null )
+                {
 
-                    _coreExpression = toSetSourceString(context, target);
-                    if (_coreExpression == null || _coreExpression.length() < 1)
-                        throw new UnsupportedCompilationException("can't find suitable getter method");
+                    context.setCurrentType( m.getReturnType() );
+                    context.setCurrentAccessor( OgnlRuntime.getCompiler().getSuperOrInterfaceClass( m,
+                                                                                                    m.getDeclaringClass() ) );
+
+                    _coreExpression = toSetSourceString( context, target );
+                    if ( _coreExpression == null || _coreExpression.length() < 1 )
+                        throw new UnsupportedCompilationException( "can't find suitable getter method" );
 
-                    _coreExpression +=  ";";
+                    _coreExpression += ";";
                     _lastExpression = "null";
 
                     return _coreExpression;
                 }
 
                 return "";
-            } else {
+            }
+            else
+            {
 
                 _getterClass = m.getReturnType();
             }
 
-            // TODO:  This is a hacky workaround until javassist supports varargs method invocations
+            // TODO: This is a hacky workaround until javassist supports varargs method invocations
 
             boolean varArgs = OgnlRuntime.isJdk15() && m.isVarArgs();
 
-            if (varArgs)
+            if ( varArgs )
             {
-                throw new UnsupportedCompilationException("Javassist does not currently support varargs method calls");
+                throw new UnsupportedCompilationException( "Javassist does not currently support varargs method calls" );
             }
 
             result = "." + m.getName() + "(";
 
-            if ((_children != null) && (_children.length > 0))
+            if ( ( _children != null ) && ( _children.length > 0 ) )
             {
                 Class[] parms = m.getParameterTypes();
-                String prevCast = (String)context.remove(ExpressionCompiler.PRE_CAST);
-/*
-                System.out.println("before children methodName is " + _methodName + " for target " + target + " target class: " + (target != null ? target.getClass() : null)
-                           + " current type: " + context.getCurrentType() + " and previous type: " + context.getPreviousType());*/
+                String prevCast = (String) context.remove( ExpressionCompiler.PRE_CAST );
+                /*
+                 * System.out.println("before children methodName is " + _methodName + " for target " + target +
+                 * " target class: " + (target != null ? target.getClass() : null) + " current type: " +
+                 * context.getCurrentType() + " and previous type: " + context.getPreviousType());
+                 */
 
-                for(int i = 0; i < _children.length; i++)
+                for ( int i = 0; i < _children.length; i++ )
                 {
-                    if (i > 0)
+                    if ( i > 0 )
                     {
                         result = result + ", ";
                     }
 
                     Class prevType = context.getCurrentType();
 
-                    context.setCurrentObject(context.getRoot());
-                    context.setCurrentType(context.getRoot() != null ? context.getRoot().getClass() : null);
-                    context.setCurrentAccessor(null);
-                    context.setPreviousType(null);
+                    context.setCurrentObject( context.getRoot() );
+                    context.setCurrentType( context.getRoot() != null ? context.getRoot().getClass() : null );
+                    context.setCurrentAccessor( null );
+                    context.setPreviousType( null );
 
-                    Object value = _children[i].getValue(context, context.getRoot());
-                    String parmString = _children[i].toGetSourceString(context, context.getRoot());
+                    Object value = _children[i].getValue( context, context.getRoot() );
+                    String parmString = _children[i].toGetSourceString( context, context.getRoot() );
 
-                    if (parmString == null || parmString.trim().length() < 1)
+                    if ( parmString == null || parmString.trim().length() < 1 )
                         parmString = "null";
 
                     // to undo type setting of constants when used as method parameters
-                    if (ASTConst.class.isInstance(_children[i]))
+                    if ( ASTConst.class.isInstance( _children[i] ) )
                     {
-                        context.setCurrentType(prevType);
+                        context.setCurrentType( prevType );
                     }
 
-                    parmString = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context) + parmString;
+                    parmString =
+                        ExpressionCompiler.getRootExpression( _children[i], context.getRoot(), context ) + parmString;
 
                     String cast = "";
-                    if (ExpressionCompiler.shouldCast(_children[i]))
+                    if ( ExpressionCompiler.shouldCast( _children[i] ) )
                     {
-                        cast = (String)context.remove(ExpressionCompiler.PRE_CAST);
+                        cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
                     }
-                    if (cast == null)
+                    if ( cast == null )
                         cast = "";
 
-                    if (!ASTConst.class.isInstance(_children[i]))
+                    if ( !ASTConst.class.isInstance( _children[i] ) )
                         parmString = cast + parmString;
 
                     Class valueClass = value != null ? value.getClass() : null;
-                    if (NodeType.class.isAssignableFrom(_children[i].getClass()))
-                        valueClass = ((NodeType)_children[i]).getGetterClass();
+                    if ( NodeType.class.isAssignableFrom( _children[i].getClass() ) )
+                        valueClass = ( (NodeType) _children[i] ).getGetterClass();
 
-                    if ((!varArgs || varArgs && (i + 1) < parms.length) && valueClass != parms[i])
+                    if ( ( !varArgs || varArgs && ( i + 1 ) < parms.length ) && valueClass != parms[i] )
                     {
-                        if (parms[i].isArray()) {
+                        if ( parms[i].isArray() )
+                        {
+
+                            parmString =
+                                OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                                "("
+                                                                                    + ExpressionCompiler.getCastString( parms[i] )
+                                                                                    + ")org.apache.commons.ognl.OgnlOps#toArray("
+                                                                                    + parmString
+                                                                                    + ", "
+                                                                                    + parms[i].getComponentType().getName()
+                                                                                    + ".class, true)", parms[i] );
+
+                        }
+                        else if ( parms[i].isPrimitive() )
+                        {
+
+                            Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( parms[i] );
+
+                            parmString =
+                                OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                                "(("
+                                                                                    + wrapClass.getName()
+                                                                                    + ")org.apache.commons.ognl.OgnlOps#convertValue("
+                                                                                    + parmString
+                                                                                    + ","
+                                                                                    + wrapClass.getName()
+                                                                                    + ".class, true))."
+                                                                                    + OgnlRuntime.getNumericValueGetter( wrapClass ),
+                                                                                parms[i] );
 
-                            parmString = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                                        "(" + ExpressionCompiler.getCastString(parms[i])
-                                                                                        + ")org.apache.commons.ognl.OgnlOps#toArray(" + parmString + ", " + parms[i].getComponentType().getName()
-                                                                                        + ".class, true)",
-                                                                                        parms[i]
-                            );
-
-                        } else  if (parms[i].isPrimitive()) {
-
-                            Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(parms[i]);
-
-                            parmString = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                                        "((" + wrapClass.getName()
-                                                                                        + ")org.apache.commons.ognl.OgnlOps#convertValue(" + parmString + ","
-                                                                                        + wrapClass.getName() + ".class, true))."
-                                                                                        + OgnlRuntime.getNumericValueGetter(wrapClass),
-                                                                                        parms[i]
-                            );
-
-                        } else if (parms[i] != Object.class) {
-                            parmString = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                                        "(" + parms[i].getName() + ")org.apache.commons.ognl.OgnlOps#convertValue(" + parmString + "," + parms[i].getName() + ".class)",
-                                                                                        parms[i]
-                            );
-                        } else if ((NodeType.class.isInstance(_children[i])
-                                    && ((NodeType)_children[i]).getGetterClass() != null
-                                    && Number.class.isAssignableFrom(((NodeType)_children[i]).getGetterClass()))
-                                   || (valueClass != null && valueClass.isPrimitive()))
+                        }
+                        else if ( parms[i] != Object.class )
+                        {
+                            parmString =
+                                OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                                "("
+                                                                                    + parms[i].getName()
+                                                                                    + ")org.apache.commons.ognl.OgnlOps#convertValue("
+                                                                                    + parmString + ","
+                                                                                    + parms[i].getName() + ".class)",
+                                                                                parms[i] );
+                        }
+                        else if ( ( NodeType.class.isInstance( _children[i] )
+                            && ( (NodeType) _children[i] ).getGetterClass() != null && Number.class.isAssignableFrom( ( (NodeType) _children[i] ).getGetterClass() ) )
+                            || ( valueClass != null && valueClass.isPrimitive() ) )
                         {
                             parmString = " ($w) " + parmString;
-                        } else if (valueClass != null && valueClass.isPrimitive())
+                        }
+                        else if ( valueClass != null && valueClass.isPrimitive() )
                         {
                             parmString = "($w) " + parmString;
                         }
@@ -307,171 +351,195 @@ public class ASTMethod extends SimpleNod
                     result += parmString;
                 }
 
-                if (prevCast != null)
+                if ( prevCast != null )
                 {
-                    context.put(ExpressionCompiler.PRE_CAST, prevCast);
+                    context.put( ExpressionCompiler.PRE_CAST, prevCast );
                 }
             }
 
-        } catch (Throwable t)
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
 
         try
         {
-            Object contextObj = getValueBody(context, target);
-            context.setCurrentObject(contextObj);
-        } catch (Throwable t)
+            Object contextObj = getValueBody( context, target );
+            context.setCurrentObject( contextObj );
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
 
         result += ")" + post;
 
-        if (m.getReturnType() == void.class) {
+        if ( m.getReturnType() == void.class )
+        {
             _coreExpression = result + ";";
             _lastExpression = "null";
         }
 
-        context.setCurrentType(m.getReturnType());
-        context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass()));
+        context.setCurrentType( m.getReturnType() );
+        context.setCurrentAccessor( OgnlRuntime.getCompiler().getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
 
         return result;
     }
 
-    public String toSetSourceString(OgnlContext context, Object target)
+    public String toSetSourceString( OgnlContext context, Object target )
     {
-        /*System.out.println("current type: " + context.getCurrentType() + " target:" + target + " " + context.getCurrentObject()
-                           + " last child? " + lastChild(context));*/
-        Method m = OgnlRuntime.getWriteMethod(context.getCurrentType() != null ?
-                context.getCurrentType() : target.getClass(),
-                                              _methodName, _children != null ? _children.length : -1);
-        if (m == null)
+        /*
+         * System.out.println("current type: " + context.getCurrentType() + " target:" + target + " " +
+         * context.getCurrentObject() + " last child? " + lastChild(context));
+         */
+        Method m =
+            OgnlRuntime.getWriteMethod( context.getCurrentType() != null ? context.getCurrentType() : target.getClass(),
+                                        _methodName, _children != null ? _children.length : -1 );
+        if ( m == null )
         {
-            throw new UnsupportedCompilationException("Unable to determine setter method generation for " + _methodName);
+            throw new UnsupportedCompilationException( "Unable to determine setter method generation for "
+                + _methodName );
         }
 
         String post = "";
         String result = "." + m.getName() + "(";
 
-        if (m.getReturnType() != void.class && m.getReturnType().isPrimitive()
-            && (_parent == null || !ASTTest.class.isInstance(_parent)))
+        if ( m.getReturnType() != void.class && m.getReturnType().isPrimitive()
+            && ( _parent == null || !ASTTest.class.isInstance( _parent ) ) )
         {
-            Class wrapper = OgnlRuntime.getPrimitiveWrapperClass(m.getReturnType());
+            Class wrapper = OgnlRuntime.getPrimitiveWrapperClass( m.getReturnType() );
 
-            ExpressionCompiler.addCastString(context, "new " + wrapper.getName() + "(");
+            ExpressionCompiler.addCastString( context, "new " + wrapper.getName() + "(" );
             post = ")";
             _getterClass = wrapper;
         }
 
         boolean varArgs = OgnlRuntime.isJdk15() && m.isVarArgs();
 
-        if (varArgs)
+        if ( varArgs )
         {
-            throw new UnsupportedCompilationException("Javassist does not currently support varargs method calls");
+            throw new UnsupportedCompilationException( "Javassist does not currently support varargs method calls" );
         }
 
-        try {
-            /* if (lastChild(context) && m.getParameterTypes().length > 0 && _children.length <= 0)
-                throw new UnsupportedCompilationException("Unable to determine setter method generation for " + m); */
+        try
+        {
+            /*
+             * if (lastChild(context) && m.getParameterTypes().length > 0 && _children.length <= 0) throw new
+             * UnsupportedCompilationException("Unable to determine setter method generation for " + m);
+             */
 
-            if ((_children != null) && (_children.length > 0))
+            if ( ( _children != null ) && ( _children.length > 0 ) )
             {
                 Class[] parms = m.getParameterTypes();
-                String prevCast = (String)context.remove(ExpressionCompiler.PRE_CAST);
+                String prevCast = (String) context.remove( ExpressionCompiler.PRE_CAST );
 
-                for(int i = 0; i < _children.length; i++)
+                for ( int i = 0; i < _children.length; i++ )
                 {
-                    if (i > 0)
+                    if ( i > 0 )
                     {
                         result += ", ";
                     }
 
                     Class prevType = context.getCurrentType();
 
-                    context.setCurrentObject(context.getRoot());
-                    context.setCurrentType(context.getRoot() != null ? context.getRoot().getClass() : null);
-                    context.setCurrentAccessor(null);
-                    context.setPreviousType(null);
+                    context.setCurrentObject( context.getRoot() );
+                    context.setCurrentType( context.getRoot() != null ? context.getRoot().getClass() : null );
+                    context.setCurrentAccessor( null );
+                    context.setPreviousType( null );
 
-                    Object value = _children[i].getValue(context, context.getRoot());
-                    String parmString = _children[i].toSetSourceString(context, context.getRoot());
+                    Object value = _children[i].getValue( context, context.getRoot() );
+                    String parmString = _children[i].toSetSourceString( context, context.getRoot() );
 
-                    if (context.getCurrentType() == Void.TYPE || context.getCurrentType() == void.class)
-                        throw new UnsupportedCompilationException("Method argument can't be a void type.");
+                    if ( context.getCurrentType() == Void.TYPE || context.getCurrentType() == void.class )
+                        throw new UnsupportedCompilationException( "Method argument can't be a void type." );
 
-                    if (parmString == null || parmString.trim().length() < 1)
+                    if ( parmString == null || parmString.trim().length() < 1 )
                     {
-                        if (ASTProperty.class.isInstance(_children[i]) || ASTMethod.class.isInstance(_children[i])
-                            || ASTStaticMethod.class.isInstance(_children[i]) || ASTChain.class.isInstance(_children[i]))
-                            throw new UnsupportedCompilationException("ASTMethod setter child returned null from a sub property expression.");
+                        if ( ASTProperty.class.isInstance( _children[i] ) || ASTMethod.class.isInstance( _children[i] )
+                            || ASTStaticMethod.class.isInstance( _children[i] )
+                            || ASTChain.class.isInstance( _children[i] ) )
+                            throw new UnsupportedCompilationException(
+                                                                       "ASTMethod setter child returned null from a sub property expression." );
 
                         parmString = "null";
                     }
 
                     // to undo type setting of constants when used as method parameters
-                    if (ASTConst.class.isInstance(_children[i]))
+                    if ( ASTConst.class.isInstance( _children[i] ) )
                     {
-                        context.setCurrentType(prevType);
+                        context.setCurrentType( prevType );
                     }
 
-                    parmString = ExpressionCompiler.getRootExpression(_children[i], context.getRoot(), context) + parmString;
+                    parmString =
+                        ExpressionCompiler.getRootExpression( _children[i], context.getRoot(), context ) + parmString;
 
                     String cast = "";
-                    if (ExpressionCompiler.shouldCast(_children[i]))
+                    if ( ExpressionCompiler.shouldCast( _children[i] ) )
                     {
-                        cast = (String)context.remove(ExpressionCompiler.PRE_CAST);
+                        cast = (String) context.remove( ExpressionCompiler.PRE_CAST );
                     }
 
-                    if (cast == null)
+                    if ( cast == null )
                         cast = "";
 
                     parmString = cast + parmString;
 
                     Class valueClass = value != null ? value.getClass() : null;
-                    if (NodeType.class.isAssignableFrom(_children[i].getClass()))
-                        valueClass = ((NodeType)_children[i]).getGetterClass();
+                    if ( NodeType.class.isAssignableFrom( _children[i].getClass() ) )
+                        valueClass = ( (NodeType) _children[i] ).getGetterClass();
 
-                    if (valueClass != parms[i])
+                    if ( valueClass != parms[i] )
                     {
-                        if (parms[i].isArray())
+                        if ( parms[i].isArray() )
                         {
-                            parmString = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                                        "(" + ExpressionCompiler.getCastString(parms[i])
-                                                                                        + ")org.apache.commons.ognl.OgnlOps#toArray(" + parmString + ", "
-                                                                                        + parms[i].getComponentType().getName()
-                                                                                        + ".class)",
-                                                                                        parms[i]
-                            );
+                            parmString =
+                                OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                                "("
+                                                                                    + ExpressionCompiler.getCastString( parms[i] )
+                                                                                    + ")org.apache.commons.ognl.OgnlOps#toArray("
+                                                                                    + parmString
+                                                                                    + ", "
+                                                                                    + parms[i].getComponentType().getName()
+                                                                                    + ".class)", parms[i] );
 
-                        } else  if (parms[i].isPrimitive())
+                        }
+                        else if ( parms[i].isPrimitive() )
                         {
-                            Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(parms[i]);
+                            Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( parms[i] );
 
-                            parmString = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                                        "((" + wrapClass.getName()
-                                                                                        + ")org.apache.commons.ognl.OgnlOps#convertValue(" + parmString + ","
-                                                                                        + wrapClass.getName() + ".class, true))."
-                                                                                        + OgnlRuntime.getNumericValueGetter(wrapClass),
-                                                                                        parms[i]
-                            );
+                            parmString =
+                                OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                                "(("
+                                                                                    + wrapClass.getName()
+                                                                                    + ")org.apache.commons.ognl.OgnlOps#convertValue("
+                                                                                    + parmString
+                                                                                    + ","
+                                                                                    + wrapClass.getName()
+                                                                                    + ".class, true))."
+                                                                                    + OgnlRuntime.getNumericValueGetter( wrapClass ),
+                                                                                parms[i] );
 
-                        } else if (parms[i] != Object.class)
+                        }
+                        else if ( parms[i] != Object.class )
                         {
-                            parmString = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                                        "(" + parms[i].getName() + ")org.apache.commons.ognl.OgnlOps#convertValue("
-                                                                                        + parmString + "," + parms[i].getName() + ".class)",
-                                                                                        parms[i]
-                            );
-
-                        } else if ((NodeType.class.isInstance(_children[i])
-                                    && ((NodeType)_children[i]).getGetterClass() != null
-                                    && Number.class.isAssignableFrom(((NodeType)_children[i]).getGetterClass()))
-                                   || (valueClass != null && valueClass.isPrimitive()))
+                            parmString =
+                                OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                                "("
+                                                                                    + parms[i].getName()
+                                                                                    + ")org.apache.commons.ognl.OgnlOps#convertValue("
+                                                                                    + parmString + ","
+                                                                                    + parms[i].getName() + ".class)",
+                                                                                parms[i] );
+
+                        }
+                        else if ( ( NodeType.class.isInstance( _children[i] )
+                            && ( (NodeType) _children[i] ).getGetterClass() != null && Number.class.isAssignableFrom( ( (NodeType) _children[i] ).getGetterClass() ) )
+                            || ( valueClass != null && valueClass.isPrimitive() ) )
                         {
                             parmString = " ($w) " + parmString;
-                        } else if (valueClass != null && valueClass.isPrimitive())
+                        }
+                        else if ( valueClass != null && valueClass.isPrimitive() )
                         {
                             parmString = "($w) " + parmString;
                         }
@@ -480,28 +548,30 @@ public class ASTMethod extends SimpleNod
                     result += parmString;
                 }
 
-                if (prevCast != null)
+                if ( prevCast != null )
                 {
-                    context.put(ExpressionCompiler.PRE_CAST, prevCast);
+                    context.put( ExpressionCompiler.PRE_CAST, prevCast );
                 }
             }
 
-        } catch (Throwable t)
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
 
         try
         {
-            Object contextObj = getValueBody(context, target);
-            context.setCurrentObject(contextObj);
-        } catch (Throwable t)
+            Object contextObj = getValueBody( context, target );
+            context.setCurrentObject( contextObj );
+        }
+        catch ( Throwable t )
         {
             // ignore
         }
 
-        context.setCurrentType(m.getReturnType());
-        context.setCurrentAccessor(OgnlRuntime.getCompiler().getSuperOrInterfaceClass(m, m.getDeclaringClass()));
+        context.setCurrentType( m.getReturnType() );
+        context.setCurrentAccessor( OgnlRuntime.getCompiler().getSuperOrInterfaceClass( m, m.getDeclaringClass() ) );
 
         return result + ")" + post;
     }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMultiply.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMultiply.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMultiply.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMultiply.java Sat May 14 13:18:29 2011
@@ -23,30 +23,35 @@ package org.apache.commons.ognl;
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-class ASTMultiply extends NumericExpression
+class ASTMultiply
+    extends NumericExpression
 {
-    
-    public ASTMultiply(int id) {
-        super(id);
+
+    public ASTMultiply( int id )
+    {
+        super( id );
     }
 
-    public ASTMultiply(OgnlParser p, int id) {
-        super(p, id);
+    public ASTMultiply( OgnlParser p, int id )
+    {
+        super( p, id );
     }
 
-    public void jjtClose() {
+    public void jjtClose()
+    {
         flattenTree();
     }
 
-    protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
+    protected Object getValueBody( OgnlContext context, Object source )
+        throws OgnlException
     {
         Object result = _children[0].getValue( context, source );
-        for ( int i=1; i < _children.length; ++i )
-            result = OgnlOps.multiply( result, _children[i].getValue(context, source) );
+        for ( int i = 1; i < _children.length; ++i )
+            result = OgnlOps.multiply( result, _children[i].getValue( context, source ) );
         return result;
     }
 
-    public String getExpressionOperator(int index)
+    public String getExpressionOperator( int index )
     {
         return "*";
     }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNegate.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNegate.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNegate.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNegate.java Sat May 14 13:18:29 2011
@@ -23,19 +23,23 @@ package org.apache.commons.ognl;
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-class ASTNegate extends NumericExpression
+class ASTNegate
+    extends NumericExpression
 {
-    public ASTNegate(int id) {
-        super(id);
+    public ASTNegate( int id )
+    {
+        super( id );
     }
 
-    public ASTNegate(OgnlParser p, int id) {
-        super(p, id);
+    public ASTNegate( OgnlParser p, int id )
+    {
+        super( p, id );
     }
 
-    protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
+    protected Object getValueBody( OgnlContext context, Object source )
+        throws OgnlException
     {
-        return OgnlOps.negate( _children[0].getValue(context, source) );
+        return OgnlOps.negate( _children[0].getValue( context, source ) );
     }
 
     public String toString()
@@ -43,14 +47,15 @@ class ASTNegate extends NumericExpressio
         return "-" + _children[0];
     }
 
-    public String toGetSourceString(OgnlContext context, Object target)
+    public String toGetSourceString( OgnlContext context, Object target )
     {
-        String source = _children[0].toGetSourceString(context, target);
+        String source = _children[0].toGetSourceString( context, target );
 
-        if (!ASTNegate.class.isInstance(_children[0]))
+        if ( !ASTNegate.class.isInstance( _children[0] ) )
         {
             return "-" + source;
-        } else
+        }
+        else
         {
             return "-(" + source + ")";
         }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNot.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNot.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNot.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNot.java Sat May 14 13:18:29 2011
@@ -23,42 +23,48 @@ package org.apache.commons.ognl;
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-class ASTNot extends BooleanExpression
+class ASTNot
+    extends BooleanExpression
 {
-    public ASTNot(int id) {
-        super(id);
+    public ASTNot( int id )
+    {
+        super( id );
     }
 
-    public ASTNot(OgnlParser p, int id) {
-        super(p, id);
+    public ASTNot( OgnlParser p, int id )
+    {
+        super( p, id );
     }
 
-    protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
+    protected Object getValueBody( OgnlContext context, Object source )
+        throws OgnlException
     {
-        return OgnlOps.booleanValue( _children[0].getValue(context, source) ) ? Boolean.FALSE : Boolean.TRUE;
+        return OgnlOps.booleanValue( _children[0].getValue( context, source ) ) ? Boolean.FALSE : Boolean.TRUE;
     }
 
-    public String getExpressionOperator(int index)
+    public String getExpressionOperator( int index )
     {
         return "!";
     }
-    
-    public String toGetSourceString(OgnlContext context, Object target)
+
+    public String toGetSourceString( OgnlContext context, Object target )
     {
-        try {
-            
-            String srcString = super.toGetSourceString(context, target);
-            
-            if (srcString == null || srcString.trim().length() < 1)
+        try
+        {
+
+            String srcString = super.toGetSourceString( context, target );
+
+            if ( srcString == null || srcString.trim().length() < 1 )
                 srcString = "null";
-            
-            context.setCurrentType(Boolean.TYPE);
+
+            context.setCurrentType( Boolean.TYPE );
 
             return "(! org.apache.commons.ognl.OgnlOps.booleanValue(" + srcString + ") )";
-            
-        } catch (Throwable t)
+
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
     }
 }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotEq.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotEq.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotEq.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotEq.java Sat May 14 13:18:29 2011
@@ -19,34 +19,37 @@
  */
 package org.apache.commons.ognl;
 
-
 /**
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-class ASTNotEq extends ComparisonExpression
+class ASTNotEq
+    extends ComparisonExpression
 {
-    public ASTNotEq(int id) {
-        super(id);
+    public ASTNotEq( int id )
+    {
+        super( id );
     }
 
-    public ASTNotEq(OgnlParser p, int id) {
-        super(p, id);
+    public ASTNotEq( OgnlParser p, int id )
+    {
+        super( p, id );
     }
 
-    protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
+    protected Object getValueBody( OgnlContext context, Object source )
+        throws OgnlException
     {
         Object v1 = _children[0].getValue( context, source );
         Object v2 = _children[1].getValue( context, source );
-        
+
         return OgnlOps.equal( v1, v2 ) ? Boolean.FALSE : Boolean.TRUE;
     }
 
-    public String getExpressionOperator(int index)
+    public String getExpressionOperator( int index )
     {
         return "!=";
     }
-    
+
     public String getComparisonFunction()
     {
         return "!org.apache.commons.ognl.OgnlOps.equal";

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotIn.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotIn.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotIn.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTNotIn.java Sat May 14 13:18:29 2011
@@ -25,59 +25,70 @@ import org.apache.commons.ognl.enhance.U
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-class ASTNotIn extends SimpleNode implements NodeType
+class ASTNotIn
+    extends SimpleNode
+    implements NodeType
 {
-    public ASTNotIn(int id) {
-        super(id);
+    public ASTNotIn( int id )
+    {
+        super( id );
     }
 
-    public ASTNotIn(OgnlParser p, int id) {
-        super(p, id);
+    public ASTNotIn( OgnlParser p, int id )
+    {
+        super( p, id );
     }
 
-    protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException
+    protected Object getValueBody( OgnlContext context, Object source )
+        throws OgnlException
     {
         Object v1 = _children[0].getValue( context, source );
         Object v2 = _children[1].getValue( context, source );
-        return OgnlOps.in( v1, v2 )? Boolean.FALSE : Boolean.TRUE;
+        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;
     }
-    
+
     public Class getSetterClass()
     {
         return null;
     }
-    
-    public String toGetSourceString(OgnlContext context, Object target)
+
+    public String toGetSourceString( OgnlContext context, Object target )
     {
-        try {
+        try
+        {
             String result = "(! org.apache.commons.ognl.OgnlOps.in( ($w) ";
-            
-            result += OgnlRuntime.getChildSource(context, target, _children[0]) + ", ($w) " + OgnlRuntime.getChildSource(context, target, _children[1]);
-            
+
+            result +=
+                OgnlRuntime.getChildSource( context, target, _children[0] ) + ", ($w) "
+                    + OgnlRuntime.getChildSource( context, target, _children[1] );
+
             result += ") )";
 
-            context.setCurrentType(Boolean.TYPE);
+            context.setCurrentType( Boolean.TYPE );
 
             return result;
-        } catch (NullPointerException e) {
-            
+        }
+        catch ( NullPointerException e )
+        {
+
             // expected to happen in some instances
             e.printStackTrace();
-            
-            throw new UnsupportedCompilationException("evaluation resulted in null expression.");
-        } catch (Throwable t)
+
+            throw new UnsupportedCompilationException( "evaluation resulted in null expression." );
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
     }
 }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTOr.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTOr.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTOr.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTOr.java Sat May 14 13:18:29 2011
@@ -26,15 +26,17 @@ import org.apache.commons.ognl.enhance.U
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-public class ASTOr extends BooleanExpression {
-    public ASTOr(int id)
+public class ASTOr
+    extends BooleanExpression
+{
+    public ASTOr( int id )
     {
-        super(id);
+        super( id );
     }
 
-    public ASTOr(OgnlParser p, int id)
+    public ASTOr( OgnlParser p, int id )
     {
-        super(p, id);
+        super( p, id );
     }
 
     public void jjtClose()
@@ -42,30 +44,34 @@ public class ASTOr extends BooleanExpres
         flattenTree();
     }
 
-    protected Object getValueBody(OgnlContext context, Object source) throws OgnlException
+    protected Object getValueBody( OgnlContext context, Object source )
+        throws OgnlException
     {
         Object result = null;
         int last = _children.length - 1;
-        for (int i = 0; i <= last; ++i) {
-            result = _children[i].getValue(context, source);
-            if (i != last && OgnlOps.booleanValue(result))
+        for ( int i = 0; i <= last; ++i )
+        {
+            result = _children[i].getValue( context, source );
+            if ( i != last && OgnlOps.booleanValue( result ) )
                 break;
         }
         return result;
     }
 
-    protected void setValueBody(OgnlContext context, Object target, Object value) throws OgnlException
+    protected void setValueBody( OgnlContext context, Object target, Object value )
+        throws OgnlException
     {
         int last = _children.length - 1;
-        for (int i = 0; i < last; ++i) {
-            Object v = _children[i].getValue(context, target);
-            if (OgnlOps.booleanValue(v))
+        for ( int i = 0; i < last; ++i )
+        {
+            Object v = _children[i].getValue( context, target );
+            if ( OgnlOps.booleanValue( v ) )
                 return;
         }
-        _children[last].setValue(context, target, value);
+        _children[last].setValue( context, target, value );
     }
 
-    public String getExpressionOperator(int index)
+    public String getExpressionOperator( int index )
     {
         return "||";
     }
@@ -75,79 +81,85 @@ public class ASTOr extends BooleanExpres
         return null;
     }
 
-    public String toGetSourceString(OgnlContext context, Object target)
+    public String toGetSourceString( OgnlContext context, Object target )
     {
-        if (_children.length != 2)
-            throw new UnsupportedCompilationException("Can only compile boolean expressions with two children.");
+        if ( _children.length != 2 )
+            throw new UnsupportedCompilationException( "Can only compile boolean expressions with two children." );
 
         String result = "(";
 
-        try {
+        try
+        {
+
+            String first = OgnlRuntime.getChildSource( context, target, _children[0] );
+            if ( !OgnlRuntime.isBoolean( first ) )
+                first = OgnlRuntime.getCompiler().createLocalReference( context, first, context.getCurrentType() );
 
-            String first = OgnlRuntime.getChildSource(context, target, _children[0]);
-            if (!OgnlRuntime.isBoolean(first))
-                first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType());
-            
             Class firstType = context.getCurrentType();
 
-            String second = OgnlRuntime.getChildSource(context, target, _children[1]);
-            if (!OgnlRuntime.isBoolean(second))
-                second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());
+            String second = OgnlRuntime.getChildSource( context, target, _children[1] );
+            if ( !OgnlRuntime.isBoolean( second ) )
+                second = OgnlRuntime.getCompiler().createLocalReference( context, second, context.getCurrentType() );
 
             Class secondType = context.getCurrentType();
 
-            boolean mismatched = (firstType.isPrimitive() && !secondType.isPrimitive())
-                                || (!firstType.isPrimitive() && secondType.isPrimitive()) ? true : false;
+            boolean mismatched =
+                ( firstType.isPrimitive() && !secondType.isPrimitive() )
+                    || ( !firstType.isPrimitive() && secondType.isPrimitive() ) ? true : false;
 
             result += "org.apache.commons.ognl.OgnlOps.booleanValue(" + first + ")";
 
             result += " ? ";
 
-            result += (mismatched ? " ($w) " : "") + first;
+            result += ( mismatched ? " ($w) " : "" ) + first;
 
             result += " : ";
 
-            result += (mismatched ? " ($w) " : "") + second;
+            result += ( mismatched ? " ($w) " : "" ) + second;
 
             result += ")";
 
-            context.setCurrentObject(target);
-            context.setCurrentType(Boolean.TYPE);
+            context.setCurrentObject( target );
+            context.setCurrentType( Boolean.TYPE );
 
-        } catch (Throwable t)
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
 
         return result;
     }
 
-    public String toSetSourceString(OgnlContext context, Object target)
+    public String toSetSourceString( OgnlContext context, Object target )
     {
-        if (_children.length != 2)
-            throw new UnsupportedCompilationException("Can only compile boolean expressions with two children.");
+        if ( _children.length != 2 )
+            throw new UnsupportedCompilationException( "Can only compile boolean expressions with two children." );
 
-        String pre = (String) context.get("_currentChain");
-        if (pre == null)
+        String pre = (String) context.get( "_currentChain" );
+        if ( pre == null )
             pre = "";
 
         String result = "";
 
-        try {
+        try
+        {
 
-            _children[0].getValue(context, target);
+            _children[0].getValue( context, target );
 
-            String first = ExpressionCompiler.getRootExpression(_children[0], context.getRoot(), context)
-                           + pre + _children[0].toGetSourceString(context, target);
-            if (!OgnlRuntime.isBoolean(first))
-                first = OgnlRuntime.getCompiler().createLocalReference(context, first, Object.class);
-
-            _children[1].getValue(context, target);
-            
-            String second = ExpressionCompiler.getRootExpression(_children[1], context.getRoot(), context)
-                            + pre + _children[1].toSetSourceString(context, target);
-            if (!OgnlRuntime.isBoolean(second))
-                second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());
+            String first =
+                ExpressionCompiler.getRootExpression( _children[0], context.getRoot(), context ) + pre
+                    + _children[0].toGetSourceString( context, target );
+            if ( !OgnlRuntime.isBoolean( first ) )
+                first = OgnlRuntime.getCompiler().createLocalReference( context, first, Object.class );
+
+            _children[1].getValue( context, target );
+
+            String second =
+                ExpressionCompiler.getRootExpression( _children[1], context.getRoot(), context ) + pre
+                    + _children[1].toSetSourceString( context, target );
+            if ( !OgnlRuntime.isBoolean( second ) )
+                second = OgnlRuntime.getCompiler().createLocalReference( context, second, context.getCurrentType() );
 
             result += "org.apache.commons.ognl.OgnlOps.booleanValue(" + first + ")";
 
@@ -158,13 +170,14 @@ public class ASTOr extends BooleanExpres
 
             result += second;
 
-            context.setCurrentObject(target);
+            context.setCurrentObject( target );
 
-            context.setCurrentType(Boolean.TYPE);
+            context.setCurrentType( Boolean.TYPE );
 
-        } catch (Throwable t)
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
 
         return result;

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProject.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProject.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProject.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProject.java Sat May 14 13:18:29 2011
@@ -29,32 +29,34 @@ import java.util.List;
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-class ASTProject extends SimpleNode
+class ASTProject
+    extends SimpleNode
 {
 
-    public ASTProject(int id)
+    public ASTProject( int id )
     {
-        super(id);
+        super( id );
     }
 
-    public ASTProject(OgnlParser p, int id)
+    public ASTProject( OgnlParser p, int id )
     {
-        super(p, id);
+        super( p, id );
     }
-    
-    protected Object getValueBody(OgnlContext context, Object source)
+
+    protected Object getValueBody( OgnlContext context, Object source )
         throws OgnlException
     {
         Node expr = _children[0];
         List answer = new ArrayList();
-        
-        ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor(OgnlRuntime.getTargetClass(source));
-        
-        for(Enumeration e = elementsAccessor.getElements(source); e.hasMoreElements();) {
-            
-            answer.add(expr.getValue(context, e.nextElement()));
+
+        ElementsAccessor elementsAccessor = OgnlRuntime.getElementsAccessor( OgnlRuntime.getTargetClass( source ) );
+
+        for ( Enumeration e = elementsAccessor.getElements( source ); e.hasMoreElements(); )
+        {
+
+            answer.add( expr.getValue( context, e.nextElement() ) );
         }
-        
+
         return answer;
     }
 
@@ -62,14 +64,14 @@ class ASTProject extends SimpleNode
     {
         return "{ " + _children[0] + " }";
     }
-    
-    public String toGetSourceString(OgnlContext context, Object target)
+
+    public String toGetSourceString( OgnlContext context, Object target )
     {
-        throw new UnsupportedCompilationException("Projection expressions not supported as native java yet.");
+        throw new UnsupportedCompilationException( "Projection expressions not supported as native java yet." );
     }
 
-    public String toSetSourceString(OgnlContext context, Object target)
+    public String toSetSourceString( OgnlContext context, Object target )
     {
-        throw new UnsupportedCompilationException("Projection expressions not supported as native java yet.");
+        throw new UnsupportedCompilationException( "Projection expressions not supported as native java yet." );
     }
 }