commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcucchi...@apache.org
Subject svn commit: r1198678 - in /commons/proper/ognl/trunk/src: main/java/org/apache/commons/ognl/OgnlRuntime.java test/java/org/apache/commons/ognl/TestOgnlRuntime.java
Date Mon, 07 Nov 2011 09:45:31 GMT
Author: mcucchiara
Date: Mon Nov  7 09:45:31 2011
New Revision: 1198678

URL: http://svn.apache.org/viewvc?rev=1198678&view=rev
Log:
Replaced for loop with foreach, added a method test

Modified:
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
    commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java?rev=1198678&r1=1198677&r2=1198678&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java Mon Nov
 7 09:45:31 2011
@@ -2031,11 +2031,15 @@ public class OgnlRuntime
         PropertyDescriptor result = null;
         PropertyDescriptor[] propertyDescriptors = getPropertyDescriptorsArray( targetClass
);
 
-        for ( int i = 0, icount = propertyDescriptors.length; ( result == null ) &&
( i < icount ); i++ )
+        for ( PropertyDescriptor propertyDescriptor : propertyDescriptors )
         {
-            if ( propertyDescriptors[i].getName().compareTo( name ) == 0 )
+            if ( result != null )
             {
-                result = propertyDescriptors[i];
+                break;
+            }
+            if ( propertyDescriptor.getName().compareTo( name ) == 0 )
+            {
+                result = propertyDescriptor;
             }
         }
         return result;

Modified: commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java?rev=1198678&r1=1198677&r2=1198678&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java (original)
+++ commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java Mon
Nov  7 09:45:31 2011
@@ -410,4 +410,13 @@ public class TestOgnlRuntime
         OgnlExpressionCompiler compiler2 = OgnlRuntime.getCompiler( context );
         assertSame( "compilers are not the same", compiler1, compiler2 );
     }
+
+    @Test
+    public void testGetPropertyDescriptorFromArray()
+        throws Exception
+    {
+        PropertyDescriptor propertyDescriptor =
+            OgnlRuntime.getPropertyDescriptorFromArray( Root.class, "disabled" );
+        assertEquals( "disabled", propertyDescriptor.getName() );
+    }
 }



Mime
View raw message