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

[commons-ognl] branch master updated: Use Java 5 for each loop

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-ognl.git


The following commit(s) were added to refs/heads/master by this push:
     new 3a1286e  Use Java 5 for each loop
3a1286e is described below

commit 3a1286e104eab5da53172777d24b4179b90b68c4
Author: Gary Gregory <gg...@rocketsoftware.com>
AuthorDate: Wed Sep 14 14:35:00 2022 -0400

    Use Java 5 for each loop
---
 src/main/java/org/apache/commons/ognl/ASTCtor.java |   7 +-
 .../java/org/apache/commons/ognl/ASTSequence.java  |   5 +-
 .../java/org/apache/commons/ognl/SimpleNode.java   | 883 ++++++++++-----------
 .../apache/commons/ognl/test/ClassMethodTest.java  |  11 +-
 .../org/apache/commons/ognl/test/ConstantTest.java |   9 +-
 .../apache/commons/ognl/test/ConstantTreeTest.java |   9 +-
 .../commons/ognl/test/ContextVariableTest.java     |   9 +-
 .../org/apache/commons/ognl/test/GenericsTest.java |  15 +-
 .../apache/commons/ognl/test/IndexAccessTest.java  |  17 +-
 .../commons/ognl/test/IndexedPropertyTest.java     |  25 +-
 .../ognl/test/InterfaceInheritanceTest.java        |  25 +-
 .../commons/ognl/test/LambdaExpressionTest.java    |  11 +-
 .../apache/commons/ognl/test/MapCreationTest.java  |  25 +-
 .../org/apache/commons/ognl/test/MethodTest.java   |  19 +-
 .../ognl/test/MethodWithConversionTest.java        |  25 +-
 .../apache/commons/ognl/test/NestedMethodTest.java |  25 +-
 .../apache/commons/ognl/test/NullHandlerTest.java  |  25 +-
 .../ognl/test/NullStringCatenationTest.java        |  11 +-
 .../commons/ognl/test/NumericConversionTest.java   |  11 +-
 .../ognl/test/ObjectIndexedPropertyTest.java       |  25 +-
 .../org/apache/commons/ognl/test/OperatorTest.java |  25 +-
 .../ognl/test/PrimitiveNullHandlingTest.java       |  25 +-
 .../commons/ognl/test/PrivateAccessorTest.java     |  25 +-
 .../commons/ognl/test/ProjectionSelectionTest.java |  11 +-
 .../PropertyArithmeticAndLogicalOperatorsTest.java |  17 +-
 .../commons/ognl/test/PropertyNotFoundTest.java    |  25 +-
 .../org/apache/commons/ognl/test/PropertyTest.java |  17 +-
 .../org/apache/commons/ognl/test/QuotingTest.java  |  25 +-
 .../org/apache/commons/ognl/test/SetterTest.java   |  25 +-
 .../ognl/test/ShortCircuitingExpressionTest.java   |   9 +-
 .../ognl/test/SimpleNavigationChainTreeTest.java   |   9 +-
 .../commons/ognl/test/SimplePropertyTreeTest.java  |   9 +-
 32 files changed, 691 insertions(+), 723 deletions(-)

diff --git a/src/main/java/org/apache/commons/ognl/ASTCtor.java b/src/main/java/org/apache/commons/ognl/ASTCtor.java
index 8d3b594..99baedc 100644
--- a/src/main/java/org/apache/commons/ognl/ASTCtor.java
+++ b/src/main/java/org/apache/commons/ognl/ASTCtor.java
@@ -248,14 +248,13 @@ public class ASTCtor
                     Constructor ctor = null;
                     Class[] ctorParamTypes = null;
 
-                    for ( int i = 0; i < cons.length; i++ )
-                    {
-                        Class[] ctorTypes = cons[i].getParameterTypes();
+                    for (Constructor con : cons) {
+                        Class[] ctorTypes = con.getParameterTypes();
 
                         if ( OgnlRuntime.areArgsCompatible( values, ctorTypes )
                             && ( ctor == null || OgnlRuntime.isMoreSpecific( ctorTypes, ctorParamTypes ) ) )
                         {
-                            ctor = cons[i];
+                            ctor = con;
                             ctorParamTypes = ctorTypes;
                         }
                     }
diff --git a/src/main/java/org/apache/commons/ognl/ASTSequence.java b/src/main/java/org/apache/commons/ognl/ASTSequence.java
index aeb765d..5f8245f 100644
--- a/src/main/java/org/apache/commons/ognl/ASTSequence.java
+++ b/src/main/java/org/apache/commons/ognl/ASTSequence.java
@@ -53,9 +53,8 @@ public class ASTSequence
         throws OgnlException
     {
         Object result = null;
-        for ( int i = 0; i < children.length; ++i )
-        {
-            result = children[i].getValue( context, source );
+        for (Node child : children) {
+            result = child.getValue( context, source );
         }
 
         return result; // The result is just the last one we saw.
diff --git a/src/main/java/org/apache/commons/ognl/SimpleNode.java b/src/main/java/org/apache/commons/ognl/SimpleNode.java
index 97f4d19..0bbb1a7 100644
--- a/src/main/java/org/apache/commons/ognl/SimpleNode.java
+++ b/src/main/java/org/apache/commons/ognl/SimpleNode.java
@@ -1,442 +1,441 @@
-package org.apache.commons.ognl;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.ognl.enhance.ExpressionAccessor;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-
-public abstract class SimpleNode
-    implements Node, Serializable
-{
-
-    private static final long serialVersionUID = 8305393337889433901L;
-
-    protected Node parent;
-
-    protected Node[] children;
-
-    protected int id;
-
-    protected OgnlParser parser;
-
-    private boolean constantValueCalculated;
-
-    private volatile boolean hasConstantValue;
-
-    private Object constantValue;
-
-    private ExpressionAccessor accessor;
-
-    public SimpleNode( int i )
-    {
-        id = i;
-    }
-
-    public SimpleNode( OgnlParser p, int i )
-    {
-        this( i );
-        parser = p;
-    }
-
-    public void jjtOpen()
-    {
-    }
-
-    public void jjtClose()
-    {
-    }
-
-    public void jjtSetParent( Node n )
-    {
-        parent = n;
-    }
-
-    public Node jjtGetParent()
-    {
-        return parent;
-    }
-
-    public void jjtAddChild( Node n, int i )
-    {
-        if ( children == null )
-        {
-            children = new Node[i + 1];
-        }
-        else if ( i >= children.length )
-        {
-            Node c[] = new Node[i + 1];
-            System.arraycopy( children, 0, c, 0, children.length );
-            children = c;
-        }
-        children[i] = n;
-    }
-
-    public Node jjtGetChild( int i )
-    {
-        return children[i];
-    }
-
-    public int jjtGetNumChildren()
-    {
-        return ( children == null ) ? 0 : children.length;
-    }
-
-    /*
-     * You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the
-     * tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding
-     * toString() is probably all you need to do.
-     */
-
-    @Override
-    public String toString()
-    {
-        final StringBuilder data = new StringBuilder();
-        try
-        {
-            accept( ToStringVisitor.INSTANCE, data );
-        }
-        catch ( OgnlException e )
-        {
-            // ignored.
-        }
-        return data.toString();
-    }
-
-    // OGNL additions
-
-    public String toString( String prefix )
-    {
-        return prefix + OgnlParserTreeConstants.jjtNodeName[id] + " " + toString();
-    }
-
-    public String toGetSourceString( OgnlContext context, Object target )
-    {
-        return toString();
-    }
-
-    public String toSetSourceString( OgnlContext context, Object target )
-    {
-        return toString();
-    }
-
-    /*
-     * Override this method if you want to customize how the node dumps out its children.
-     */
-
-    public void dump( PrintWriter writer, String prefix )
-    {
-        writer.println( toString( prefix ) );
-
-        if ( children != null )
-        {
-            for ( int i = 0; i < children.length; ++i )
-            {
-                SimpleNode n = (SimpleNode) children[i];
-                if ( n != null )
-                {
-                    n.dump( writer, prefix + "  " );
-                }
-            }
-        }
-    }
-
-    public int getIndexInParent()
-    {
-        int result = -1;
-
-        if ( parent != null )
-        {
-            int icount = parent.jjtGetNumChildren();
-
-            for ( int i = 0; i < icount; i++ )
-            {
-                if ( parent.jjtGetChild( i ) == this )
-                {
-                    result = i;
-                    break;
-                }
-            }
-        }
-
-        return result;
-    }
-
-    public Node getNextSibling()
-    {
-        Node result = null;
-        int i = getIndexInParent();
-
-        if ( i >= 0 )
-        {
-            int icount = parent.jjtGetNumChildren();
-
-            if ( i < icount )
-            {
-                result = parent.jjtGetChild( i + 1 );
-            }
-        }
-        return result;
-    }
-
-    protected Object evaluateGetValueBody( OgnlContext context, Object source )
-        throws OgnlException
-    {
-        context.setCurrentObject( source );
-        context.setCurrentNode( this );
-
-        if ( !constantValueCalculated )
-        {
-            constantValueCalculated = true;
-            boolean constant = isConstant( context );
-
-            if ( constant )
-            {
-                constantValue = getValueBody( context, source );
-            }
-
-            hasConstantValue = constant;
-        }
-
-        return hasConstantValue ? constantValue : getValueBody( context, source );
-    }
-
-    protected void evaluateSetValueBody( OgnlContext context, Object target, Object value )
-        throws OgnlException
-    {
-        context.setCurrentObject( target );
-        context.setCurrentNode( this );
-        setValueBody( context, target, value );
-    }
-
-    public final Object getValue( OgnlContext context, Object source )
-        throws OgnlException
-    {
-        Object result = null;
-
-        if ( context.getTraceEvaluations() )
-        {
-
-            Throwable evalException = null;
-            Evaluation evaluation = new Evaluation( this, source );
-
-            context.pushEvaluation( evaluation );
-            try
-            {
-                result = evaluateGetValueBody( context, source );
-            }
-            catch ( OgnlException | RuntimeException ex )
-            {
-                evalException = ex;
-                throw ex;
-            } finally
-            {
-                Evaluation eval = context.popEvaluation();
-
-                eval.setResult( result );
-                if ( evalException != null )
-                {
-                    eval.setException( evalException );
-                }
-            }
-        }
-        else
-        {
-            result = evaluateGetValueBody( context, source );
-        }
-
-        return result;
-    }
-
-    /**
-     * Subclasses implement this method to do the actual work of extracting the appropriate value from the source
-     * object.
-     */
-    protected abstract Object getValueBody( OgnlContext context, Object source )
-        throws OgnlException;
-
-    public final void setValue( OgnlContext context, Object target, Object value )
-        throws OgnlException
-    {
-        if ( context.getTraceEvaluations() )
-        {
-            Throwable evalException = null;
-            Evaluation evaluation = new Evaluation( this, target, true );
-
-            context.pushEvaluation( evaluation );
-            try
-            {
-                evaluateSetValueBody( context, target, value );
-            }
-            catch ( OgnlException ex )
-            {
-                evalException = ex;
-                ex.setEvaluation( evaluation );
-                throw ex;
-            }
-            catch ( RuntimeException ex )
-            {
-                evalException = ex;
-                throw ex;
-            }
-            finally
-            {
-                Evaluation eval = context.popEvaluation();
-
-                if ( evalException != null )
-                {
-                    eval.setException( evalException );
-                }
-            }
-        }
-        else
-        {
-            evaluateSetValueBody( context, target, value );
-        }
-    }
-
-    /**
-     * Subclasses implement this method to do the actual work of setting the appropriate value in the target object. The
-     * default implementation throws an <code>InappropriateExpressionException</code>, meaning that it cannot be a set
-     * expression.
-     */
-    protected void setValueBody( OgnlContext context, Object target, Object value )
-        throws OgnlException
-    {
-        throw new InappropriateExpressionException( this );
-    }
-
-    /** Returns true iff this node is constant without respect to the children. */
-    public boolean isNodeConstant( OgnlContext context )
-        throws OgnlException
-    {
-        return false;
-    }
-
-    public boolean isConstant( OgnlContext context )
-        throws OgnlException
-    {
-        return isNodeConstant( context );
-    }
-
-    public boolean isNodeSimpleProperty( OgnlContext context )
-        throws OgnlException
-    {
-        return false;
-    }
-
-    public boolean isSimpleProperty( OgnlContext context )
-        throws OgnlException
-    {
-        return isNodeSimpleProperty( context );
-    }
-
-    public boolean isSimpleNavigationChain( OgnlContext context )
-        throws OgnlException
-    {
-        return isSimpleProperty( context );
-    }
-
-    public boolean isEvalChain( OgnlContext context )
-        throws OgnlException
-    {
-        if ( children == null )
-        {
-            return false;
-        }
-        for ( Node child : children )
-        {
-            if ( child instanceof SimpleNode && ( (SimpleNode) child ).isEvalChain( context ) )
-            {
-                return true;
-            }
-
-        }
-        return false;
-    }
-
-    protected boolean lastChild( OgnlContext context )
-    {
-        return parent == null || context.get( "_lastChild" ) != null;
-    }
-
-    /**
-     * This method may be called from subclasses' jjtClose methods. It flattens the tree under this node by eliminating
-     * any children that are of the same class as this node and copying their children to this node.
-     */
-    protected void flattenTree()
-    {
-        boolean shouldFlatten = false;
-        int newSize = 0;
-
-        for ( Node aChildren : children )
-        {
-            if ( aChildren.getClass() == getClass() )
-            {
-                shouldFlatten = true;
-                newSize += aChildren.jjtGetNumChildren();
-            }
-            else
-            {
-                ++newSize;
-            }
-        }
-
-        if ( shouldFlatten )
-        {
-            Node[] newChildren = new Node[newSize];
-            int j = 0;
-
-            for ( Node c : children )
-            {
-                if ( c.getClass() == getClass() )
-                {
-                    for ( int k = 0; k < c.jjtGetNumChildren(); ++k )
-                    {
-                        newChildren[j++] = c.jjtGetChild( k );
-                    }
-
-                }
-                else
-                {
-                    newChildren[j++] = c;
-                }
-            }
-
-            if ( j != newSize )
-            {
-                throw new Error( "Assertion error: " + j + " != " + newSize );
-            }
-
-            children = newChildren;
-        }
-    }
-
-    public ExpressionAccessor getAccessor()
-    {
-        return accessor;
-    }
-
-    public void setAccessor( ExpressionAccessor accessor )
-    {
-        this.accessor = accessor;
-    }
-}
+package org.apache.commons.ognl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.ognl.enhance.ExpressionAccessor;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+
+public abstract class SimpleNode
+    implements Node, Serializable
+{
+
+    private static final long serialVersionUID = 8305393337889433901L;
+
+    protected Node parent;
+
+    protected Node[] children;
+
+    protected int id;
+
+    protected OgnlParser parser;
+
+    private boolean constantValueCalculated;
+
+    private volatile boolean hasConstantValue;
+
+    private Object constantValue;
+
+    private ExpressionAccessor accessor;
+
+    public SimpleNode( int i )
+    {
+        id = i;
+    }
+
+    public SimpleNode( OgnlParser p, int i )
+    {
+        this( i );
+        parser = p;
+    }
+
+    public void jjtOpen()
+    {
+    }
+
+    public void jjtClose()
+    {
+    }
+
+    public void jjtSetParent( Node n )
+    {
+        parent = n;
+    }
+
+    public Node jjtGetParent()
+    {
+        return parent;
+    }
+
+    public void jjtAddChild( Node n, int i )
+    {
+        if ( children == null )
+        {
+            children = new Node[i + 1];
+        }
+        else if ( i >= children.length )
+        {
+            Node c[] = new Node[i + 1];
+            System.arraycopy( children, 0, c, 0, children.length );
+            children = c;
+        }
+        children[i] = n;
+    }
+
+    public Node jjtGetChild( int i )
+    {
+        return children[i];
+    }
+
+    public int jjtGetNumChildren()
+    {
+        return ( children == null ) ? 0 : children.length;
+    }
+
+    /*
+     * You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the
+     * tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding
+     * toString() is probably all you need to do.
+     */
+
+    @Override
+    public String toString()
+    {
+        final StringBuilder data = new StringBuilder();
+        try
+        {
+            accept( ToStringVisitor.INSTANCE, data );
+        }
+        catch ( OgnlException e )
+        {
+            // ignored.
+        }
+        return data.toString();
+    }
+
+    // OGNL additions
+
+    public String toString( String prefix )
+    {
+        return prefix + OgnlParserTreeConstants.jjtNodeName[id] + " " + toString();
+    }
+
+    public String toGetSourceString( OgnlContext context, Object target )
+    {
+        return toString();
+    }
+
+    public String toSetSourceString( OgnlContext context, Object target )
+    {
+        return toString();
+    }
+
+    /*
+     * Override this method if you want to customize how the node dumps out its children.
+     */
+
+    public void dump( PrintWriter writer, String prefix )
+    {
+        writer.println( toString( prefix ) );
+
+        if ( children != null )
+        {
+            for (Node child : children) {
+                SimpleNode n = (SimpleNode) child;
+                if ( n != null )
+                {
+                    n.dump( writer, prefix + "  " );
+                }
+            }
+        }
+    }
+
+    public int getIndexInParent()
+    {
+        int result = -1;
+
+        if ( parent != null )
+        {
+            int icount = parent.jjtGetNumChildren();
+
+            for ( int i = 0; i < icount; i++ )
+            {
+                if ( parent.jjtGetChild( i ) == this )
+                {
+                    result = i;
+                    break;
+                }
+            }
+        }
+
+        return result;
+    }
+
+    public Node getNextSibling()
+    {
+        Node result = null;
+        int i = getIndexInParent();
+
+        if ( i >= 0 )
+        {
+            int icount = parent.jjtGetNumChildren();
+
+            if ( i < icount )
+            {
+                result = parent.jjtGetChild( i + 1 );
+            }
+        }
+        return result;
+    }
+
+    protected Object evaluateGetValueBody( OgnlContext context, Object source )
+        throws OgnlException
+    {
+        context.setCurrentObject( source );
+        context.setCurrentNode( this );
+
+        if ( !constantValueCalculated )
+        {
+            constantValueCalculated = true;
+            boolean constant = isConstant( context );
+
+            if ( constant )
+            {
+                constantValue = getValueBody( context, source );
+            }
+
+            hasConstantValue = constant;
+        }
+
+        return hasConstantValue ? constantValue : getValueBody( context, source );
+    }
+
+    protected void evaluateSetValueBody( OgnlContext context, Object target, Object value )
+        throws OgnlException
+    {
+        context.setCurrentObject( target );
+        context.setCurrentNode( this );
+        setValueBody( context, target, value );
+    }
+
+    public final Object getValue( OgnlContext context, Object source )
+        throws OgnlException
+    {
+        Object result = null;
+
+        if ( context.getTraceEvaluations() )
+        {
+
+            Throwable evalException = null;
+            Evaluation evaluation = new Evaluation( this, source );
+
+            context.pushEvaluation( evaluation );
+            try
+            {
+                result = evaluateGetValueBody( context, source );
+            }
+            catch ( OgnlException | RuntimeException ex )
+            {
+                evalException = ex;
+                throw ex;
+            } finally
+            {
+                Evaluation eval = context.popEvaluation();
+
+                eval.setResult( result );
+                if ( evalException != null )
+                {
+                    eval.setException( evalException );
+                }
+            }
+        }
+        else
+        {
+            result = evaluateGetValueBody( context, source );
+        }
+
+        return result;
+    }
+
+    /**
+     * Subclasses implement this method to do the actual work of extracting the appropriate value from the source
+     * object.
+     */
+    protected abstract Object getValueBody( OgnlContext context, Object source )
+        throws OgnlException;
+
+    public final void setValue( OgnlContext context, Object target, Object value )
+        throws OgnlException
+    {
+        if ( context.getTraceEvaluations() )
+        {
+            Throwable evalException = null;
+            Evaluation evaluation = new Evaluation( this, target, true );
+
+            context.pushEvaluation( evaluation );
+            try
+            {
+                evaluateSetValueBody( context, target, value );
+            }
+            catch ( OgnlException ex )
+            {
+                evalException = ex;
+                ex.setEvaluation( evaluation );
+                throw ex;
+            }
+            catch ( RuntimeException ex )
+            {
+                evalException = ex;
+                throw ex;
+            }
+            finally
+            {
+                Evaluation eval = context.popEvaluation();
+
+                if ( evalException != null )
+                {
+                    eval.setException( evalException );
+                }
+            }
+        }
+        else
+        {
+            evaluateSetValueBody( context, target, value );
+        }
+    }
+
+    /**
+     * Subclasses implement this method to do the actual work of setting the appropriate value in the target object. The
+     * default implementation throws an <code>InappropriateExpressionException</code>, meaning that it cannot be a set
+     * expression.
+     */
+    protected void setValueBody( OgnlContext context, Object target, Object value )
+        throws OgnlException
+    {
+        throw new InappropriateExpressionException( this );
+    }
+
+    /** Returns true iff this node is constant without respect to the children. */
+    public boolean isNodeConstant( OgnlContext context )
+        throws OgnlException
+    {
+        return false;
+    }
+
+    public boolean isConstant( OgnlContext context )
+        throws OgnlException
+    {
+        return isNodeConstant( context );
+    }
+
+    public boolean isNodeSimpleProperty( OgnlContext context )
+        throws OgnlException
+    {
+        return false;
+    }
+
+    public boolean isSimpleProperty( OgnlContext context )
+        throws OgnlException
+    {
+        return isNodeSimpleProperty( context );
+    }
+
+    public boolean isSimpleNavigationChain( OgnlContext context )
+        throws OgnlException
+    {
+        return isSimpleProperty( context );
+    }
+
+    public boolean isEvalChain( OgnlContext context )
+        throws OgnlException
+    {
+        if ( children == null )
+        {
+            return false;
+        }
+        for ( Node child : children )
+        {
+            if ( child instanceof SimpleNode && ( (SimpleNode) child ).isEvalChain( context ) )
+            {
+                return true;
+            }
+
+        }
+        return false;
+    }
+
+    protected boolean lastChild( OgnlContext context )
+    {
+        return parent == null || context.get( "_lastChild" ) != null;
+    }
+
+    /**
+     * This method may be called from subclasses' jjtClose methods. It flattens the tree under this node by eliminating
+     * any children that are of the same class as this node and copying their children to this node.
+     */
+    protected void flattenTree()
+    {
+        boolean shouldFlatten = false;
+        int newSize = 0;
+
+        for ( Node aChildren : children )
+        {
+            if ( aChildren.getClass() == getClass() )
+            {
+                shouldFlatten = true;
+                newSize += aChildren.jjtGetNumChildren();
+            }
+            else
+            {
+                ++newSize;
+            }
+        }
+
+        if ( shouldFlatten )
+        {
+            Node[] newChildren = new Node[newSize];
+            int j = 0;
+
+            for ( Node c : children )
+            {
+                if ( c.getClass() == getClass() )
+                {
+                    for ( int k = 0; k < c.jjtGetNumChildren(); ++k )
+                    {
+                        newChildren[j++] = c.jjtGetChild( k );
+                    }
+
+                }
+                else
+                {
+                    newChildren[j++] = c;
+                }
+            }
+
+            if ( j != newSize )
+            {
+                throw new Error( "Assertion error: " + j + " != " + newSize );
+            }
+
+            children = newChildren;
+        }
+    }
+
+    public ExpressionAccessor getAccessor()
+    {
+        return accessor;
+    }
+
+    public void setAccessor( ExpressionAccessor accessor )
+    {
+        this.accessor = accessor;
+    }
+}
diff --git a/src/test/java/org/apache/commons/ognl/test/ClassMethodTest.java b/src/test/java/org/apache/commons/ognl/test/ClassMethodTest.java
index 0de3ba6..dbedb42 100644
--- a/src/test/java/org/apache/commons/ognl/test/ClassMethodTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ClassMethodTest.java
@@ -52,13 +52,12 @@ public class ClassMethodTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
-            tmp[3] = TESTS[i][2];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
+            tmp[3] = element[2];
             tmp[4] = null;
             tmp[5] = null;
 
diff --git a/src/test/java/org/apache/commons/ognl/test/ConstantTest.java b/src/test/java/org/apache/commons/ognl/test/ConstantTest.java
index 4a4eea6..3b518be 100644
--- a/src/test/java/org/apache/commons/ognl/test/ConstantTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ConstantTest.java
@@ -72,13 +72,12 @@ public class ConstantTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+            tmp[0] = element[0] + " (" + element[1] + ")";
             tmp[1] = null;
-            tmp[2] = TESTS[i][0];
-            tmp[3] = TESTS[i][1];
+            tmp[2] = element[0];
+            tmp[3] = element[1];
             tmp[4] = null;
             tmp[5] = null;
 
diff --git a/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java b/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java
index 5ccc2c9..022f331 100644
--- a/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ConstantTreeTest.java
@@ -54,13 +54,12 @@ public class ConstantTreeTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+            tmp[0] = element[0] + " (" + element[1] + ")";
             tmp[1] = null;
-            tmp[2] = TESTS[i][0];
-            tmp[3] = TESTS[i][1];
+            tmp[2] = element[0];
+            tmp[3] = element[1];
             tmp[4] = null;
             tmp[5] = null;
 
diff --git a/src/test/java/org/apache/commons/ognl/test/ContextVariableTest.java b/src/test/java/org/apache/commons/ognl/test/ContextVariableTest.java
index d84fd1e..7d0a52d 100644
--- a/src/test/java/org/apache/commons/ognl/test/ContextVariableTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ContextVariableTest.java
@@ -47,13 +47,12 @@ public class ContextVariableTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+            tmp[0] = element[0] + " (" + element[1] + ")";
             tmp[1] = ROOT;
-            tmp[2] = TESTS[i][0];
-            tmp[3] = TESTS[i][1];
+            tmp[2] = element[0];
+            tmp[3] = element[1];
             tmp[4] = null;
             tmp[5] = null;
 
diff --git a/src/test/java/org/apache/commons/ognl/test/GenericsTest.java b/src/test/java/org/apache/commons/ognl/test/GenericsTest.java
index 8cc80e6..4ffb377 100644
--- a/src/test/java/org/apache/commons/ognl/test/GenericsTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/GenericsTest.java
@@ -50,15 +50,14 @@ public class GenericsTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1] + " (" + TESTS[i][2] + ")";
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
-            tmp[3] = TESTS[i][2];
-            tmp[4] = TESTS[i][3];
-            tmp[5] = TESTS[i][4];
+            tmp[0] = element[1] + " (" + element[2] + ")";
+            tmp[1] = element[0];
+            tmp[2] = element[1];
+            tmp[3] = element[2];
+            tmp[4] = element[3];
+            tmp[5] = element[4];
 
             data.add( tmp );
         }
diff --git a/src/test/java/org/apache/commons/ognl/test/IndexAccessTest.java b/src/test/java/org/apache/commons/ognl/test/IndexAccessTest.java
index 6ec636c..b5c68e9 100644
--- a/src/test/java/org/apache/commons/ognl/test/IndexAccessTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/IndexAccessTest.java
@@ -66,18 +66,17 @@ public class IndexAccessTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
-            tmp[3] = TESTS[i][2];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
+            tmp[3] = element[2];
 
-            if ( TESTS[i].length == 5 )
+            if ( element.length == 5 )
             {
-                tmp[4] = TESTS[i][3];
-                tmp[5] = TESTS[i][4];
+                tmp[4] = element[3];
+                tmp[5] = element[4];
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/IndexedPropertyTest.java b/src/test/java/org/apache/commons/ognl/test/IndexedPropertyTest.java
index a67e20f..b0386f0 100644
--- a/src/test/java/org/apache/commons/ognl/test/IndexedPropertyTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/IndexedPropertyTest.java
@@ -61,32 +61,31 @@ public class IndexedPropertyTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/InterfaceInheritanceTest.java b/src/test/java/org/apache/commons/ognl/test/InterfaceInheritanceTest.java
index 5875856..78a793d 100644
--- a/src/test/java/org/apache/commons/ognl/test/InterfaceInheritanceTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/InterfaceInheritanceTest.java
@@ -75,32 +75,31 @@ public class InterfaceInheritanceTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/LambdaExpressionTest.java b/src/test/java/org/apache/commons/ognl/test/LambdaExpressionTest.java
index b4f1f22..055f03f 100644
--- a/src/test/java/org/apache/commons/ognl/test/LambdaExpressionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/LambdaExpressionTest.java
@@ -54,13 +54,12 @@ public class LambdaExpressionTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
-            tmp[3] = TESTS[i][2];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
+            tmp[3] = element[2];
 
             data.add( tmp );
         }
diff --git a/src/test/java/org/apache/commons/ognl/test/MapCreationTest.java b/src/test/java/org/apache/commons/ognl/test/MapCreationTest.java
index 9c4fcc6..56101a6 100644
--- a/src/test/java/org/apache/commons/ognl/test/MapCreationTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/MapCreationTest.java
@@ -78,32 +78,31 @@ public class MapCreationTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/MethodTest.java b/src/test/java/org/apache/commons/ognl/test/MethodTest.java
index 15a7c1d..451ea6c 100644
--- a/src/test/java/org/apache/commons/ognl/test/MethodTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/MethodTest.java
@@ -71,23 +71,22 @@ public class MethodTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
 
-            if ( TESTS[i].length == 3 )
+            if ( element.length == 3 )
             {
-                tmp[0] = TESTS[i][1] + " (" + TESTS[i][2] + ")";
-                tmp[1] = TESTS[i][0];
-                tmp[2] = TESTS[i][1];
-                tmp[3] = TESTS[i][2];
+                tmp[0] = element[1] + " (" + element[2] + ")";
+                tmp[1] = element[0];
+                tmp[2] = element[1];
+                tmp[3] = element[2];
             }
             else
             {
-                tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+                tmp[0] = element[0] + " (" + element[1] + ")";
                 tmp[1] = ROOT;
-                tmp[2] = TESTS[i][0];
-                tmp[3] = TESTS[i][1];
+                tmp[2] = element[0];
+                tmp[3] = element[1];
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/MethodWithConversionTest.java b/src/test/java/org/apache/commons/ognl/test/MethodWithConversionTest.java
index aaacabb..4d3d4e9 100644
--- a/src/test/java/org/apache/commons/ognl/test/MethodWithConversionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/MethodWithConversionTest.java
@@ -50,32 +50,31 @@ public class MethodWithConversionTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/NestedMethodTest.java b/src/test/java/org/apache/commons/ognl/test/NestedMethodTest.java
index 302a328..0546803 100644
--- a/src/test/java/org/apache/commons/ognl/test/NestedMethodTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NestedMethodTest.java
@@ -48,32 +48,31 @@ public class NestedMethodTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java b/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java
index 0af5bf0..b5d74ae 100644
--- a/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NullHandlerTest.java
@@ -48,32 +48,31 @@ public class NullHandlerTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java b/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java
index a09627b..d289e9b 100644
--- a/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NullStringCatenationTest.java
@@ -60,13 +60,12 @@ public class NullStringCatenationTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[4];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
-            tmp[3] = TESTS[i][2];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
+            tmp[3] = element[2];
 
             data.add( tmp );
         }
diff --git a/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java b/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
index fe8c3eb..0e22e86 100644
--- a/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/NumericConversionTest.java
@@ -166,13 +166,12 @@ public class NumericConversionTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[4];
-            tmp[0] = TESTS[i][0];
-            tmp[1] = TESTS[i][1];
-            tmp[2] = TESTS[i][2];
-            tmp[3] = ( TESTS[i].length > 3 ) ? ( (Integer) TESTS[i][3] ).intValue() : -1 ;
+            tmp[0] = element[0];
+            tmp[1] = element[1];
+            tmp[2] = element[2];
+            tmp[3] = ( element.length > 3 ) ? ( (Integer) element[3] ).intValue() : -1 ;
 
             data.add( tmp );
         }
diff --git a/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java b/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java
index f7434e4..2c1002f 100644
--- a/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ObjectIndexedPropertyTest.java
@@ -70,32 +70,31 @@ public class ObjectIndexedPropertyTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/OperatorTest.java b/src/test/java/org/apache/commons/ognl/test/OperatorTest.java
index 5ed64bc..652f79e 100644
--- a/src/test/java/org/apache/commons/ognl/test/OperatorTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/OperatorTest.java
@@ -46,32 +46,31 @@ public class OperatorTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java b/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java
index f89d128..8b8fcc6 100644
--- a/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PrimitiveNullHandlingTest.java
@@ -63,32 +63,31 @@ public class PrimitiveNullHandlingTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java b/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java
index e9a8537..1f9b1c7 100644
--- a/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PrivateAccessorTest.java
@@ -56,32 +56,31 @@ public class PrivateAccessorTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java b/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java
index d5d9f42..e8637e0 100644
--- a/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ProjectionSelectionTest.java
@@ -53,13 +53,12 @@ public class ProjectionSelectionTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
-            tmp[3] = TESTS[i][2];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
+            tmp[3] = element[2];
 
             data.add( tmp );
         }
diff --git a/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java b/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java
index 0d17170..c1e898f 100644
--- a/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PropertyArithmeticAndLogicalOperatorsTest.java
@@ -73,18 +73,17 @@ public class PropertyArithmeticAndLogicalOperatorsTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
-            tmp[3] = TESTS[i][2];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
+            tmp[3] = element[2];
 
-            if ( TESTS[i].length == 5 )
+            if ( element.length == 5 )
             {
-                tmp[4] = TESTS[i][3];
-                tmp[5] = TESTS[i][4];
+                tmp[4] = element[3];
+                tmp[5] = element[4];
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java b/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java
index 1b00d95..501a6c2 100644
--- a/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PropertyNotFoundTest.java
@@ -108,32 +108,31 @@ public class PropertyNotFoundTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/PropertyTest.java b/src/test/java/org/apache/commons/ognl/test/PropertyTest.java
index 4630d64..7024907 100644
--- a/src/test/java/org/apache/commons/ognl/test/PropertyTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/PropertyTest.java
@@ -140,18 +140,17 @@ public class PropertyTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
-            tmp[3] = TESTS[i][2];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
+            tmp[3] = element[2];
 
-            if ( TESTS[i].length == 5 )
+            if ( element.length == 5 )
             {
-                tmp[4] = TESTS[i][3];
-                tmp[5] = TESTS[i][4];
+                tmp[4] = element[3];
+                tmp[5] = element[4];
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/QuotingTest.java b/src/test/java/org/apache/commons/ognl/test/QuotingTest.java
index 81c5e1c..63f63bd 100644
--- a/src/test/java/org/apache/commons/ognl/test/QuotingTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/QuotingTest.java
@@ -44,32 +44,31 @@ public class QuotingTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/SetterTest.java b/src/test/java/org/apache/commons/ognl/test/SetterTest.java
index 06dc515..90e0e29 100644
--- a/src/test/java/org/apache/commons/ognl/test/SetterTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/SetterTest.java
@@ -73,32 +73,31 @@ public class SetterTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][1];
-            tmp[1] = TESTS[i][0];
-            tmp[2] = TESTS[i][1];
+            tmp[0] = element[1];
+            tmp[1] = element[0];
+            tmp[2] = element[1];
 
-            switch ( TESTS[i].length )
+            switch ( element.length )
             {
                 case 3:
-                    tmp[3] = TESTS[i][2];
+                    tmp[3] = element[2];
                     break;
 
                 case 4:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
                     break;
 
                 case 5:
-                    tmp[3] = TESTS[i][2];
-                    tmp[4] = TESTS[i][3];
-                    tmp[5] = TESTS[i][4];
+                    tmp[3] = element[2];
+                    tmp[4] = element[3];
+                    tmp[5] = element[4];
                     break;
 
                 default:
-                    throw new RuntimeException( "don't understand TEST format with length " + TESTS[i].length );
+                    throw new RuntimeException( "don't understand TEST format with length " + element.length );
             }
 
             data.add( tmp );
diff --git a/src/test/java/org/apache/commons/ognl/test/ShortCircuitingExpressionTest.java b/src/test/java/org/apache/commons/ognl/test/ShortCircuitingExpressionTest.java
index 71201e2..f65704d 100644
--- a/src/test/java/org/apache/commons/ognl/test/ShortCircuitingExpressionTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/ShortCircuitingExpressionTest.java
@@ -46,13 +46,12 @@ public class ShortCircuitingExpressionTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+            tmp[0] = element[0] + " (" + element[1] + ")";
             tmp[1] = null;
-            tmp[2] = TESTS[i][0];
-            tmp[3] = TESTS[i][1];
+            tmp[2] = element[0];
+            tmp[3] = element[1];
 
             data.add( tmp );
         }
diff --git a/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java b/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java
index fc06bf1..e51f035 100644
--- a/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/SimpleNavigationChainTreeTest.java
@@ -46,13 +46,12 @@ public class SimpleNavigationChainTreeTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+            tmp[0] = element[0] + " (" + element[1] + ")";
             tmp[1] = null;
-            tmp[2] = TESTS[i][0];
-            tmp[3] = TESTS[i][1];
+            tmp[2] = element[0];
+            tmp[3] = element[1];
 
             data.add( tmp );
         }
diff --git a/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java b/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java
index b4d8411..37c4e10 100644
--- a/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java
+++ b/src/test/java/org/apache/commons/ognl/test/SimplePropertyTreeTest.java
@@ -46,13 +46,12 @@ public class SimplePropertyTreeTest
     public static Collection<Object[]> data()
     {
         Collection<Object[]> data = new ArrayList<Object[]>(TESTS.length);
-        for ( int i = 0; i < TESTS.length; i++ )
-        {
+        for (Object[] element : TESTS) {
             Object[] tmp = new Object[6];
-            tmp[0] = TESTS[i][0] + " (" + TESTS[i][1] + ")";
+            tmp[0] = element[0] + " (" + element[1] + ")";
             tmp[1] = null;
-            tmp[2] = TESTS[i][0];
-            tmp[3] = TESTS[i][1];
+            tmp[2] = element[0];
+            tmp[3] = element[1];
 
             data.add( tmp );
         }