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 [8/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/ObjectArrayPool.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectArrayPool.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectArrayPool.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectArrayPool.java Sat May 14 13:18:29 2011
@@ -21,30 +21,38 @@ package org.apache.commons.ognl;
 
 import java.util.*;
 
-public final class ObjectArrayPool extends Object
+public final class ObjectArrayPool
+    extends Object
 {
-    private IntHashMap      pools = new IntHashMap(23);
+    private IntHashMap pools = new IntHashMap( 23 );
 
-    public static class SizePool extends Object
+    public static class SizePool
+        extends Object
     {
-        private List        arrays = new ArrayList();
-        private int         arraySize;
-        private int         size;
-        private int         created = 0;
-        private int         recovered = 0;
-        private int         recycled = 0;
+        private List arrays = new ArrayList();
 
-        public SizePool(int arraySize)
+        private int arraySize;
+
+        private int size;
+
+        private int created = 0;
+
+        private int recovered = 0;
+
+        private int recycled = 0;
+
+        public SizePool( int arraySize )
         {
-            this(arraySize, 0);
+            this( arraySize, 0 );
         }
 
-        public SizePool(int arraySize, int initialSize)
+        public SizePool( int arraySize, int initialSize )
         {
             super();
             this.arraySize = arraySize;
-            for (int i = 0; i < initialSize; i++) {
-                arrays.add(new Object[arraySize]);
+            for ( int i = 0; i < initialSize; i++ )
+            {
+                arrays.add( new Object[arraySize] );
             }
             created = size = initialSize;
         }
@@ -56,36 +64,44 @@ public final class ObjectArrayPool exten
 
         public Object[] create()
         {
-            Object[]        result;
+            Object[] result;
 
-            if (size > 0) {
-                result = (Object[])arrays.remove(size - 1);
+            if ( size > 0 )
+            {
+                result = (Object[]) arrays.remove( size - 1 );
                 size--;
                 recovered++;
-            } else {
+            }
+            else
+            {
                 result = new Object[arraySize];
                 created++;
             }
             return result;
         }
 
-        public synchronized void recycle(Object[] value)
+        public synchronized void recycle( Object[] value )
         {
-            if (value != null) {
-                if (value.length != arraySize) {
-                    throw new IllegalArgumentException("recycled array size " + value.length + " inappropriate for pool array size " + arraySize);
+            if ( value != null )
+            {
+                if ( value.length != arraySize )
+                {
+                    throw new IllegalArgumentException( "recycled array size " + value.length
+                        + " inappropriate for pool array size " + arraySize );
                 }
-                Arrays.fill(value, null);
-                arrays.add(value);
+                Arrays.fill( value, null );
+                arrays.add( value );
                 size++;
                 recycled++;
-            } else {
-                throw new IllegalArgumentException("cannot recycle null object");
+            }
+            else
+            {
+                throw new IllegalArgumentException( "cannot recycle null object" );
             }
         }
 
         /**
-            Returns the number of items in the pool
+         * Returns the number of items in the pool
          */
         public int getSize()
         {
@@ -93,8 +109,7 @@ public final class ObjectArrayPool exten
         }
 
         /**
-            Returns the number of items this pool has created since
-            it's construction.
+         * Returns the number of items this pool has created since it's construction.
          */
         public int getCreatedCount()
         {
@@ -102,8 +117,7 @@ public final class ObjectArrayPool exten
         }
 
         /**
-            Returns the number of items this pool has recovered from
-            the pool since its construction.
+         * Returns the number of items this pool has recovered from the pool since its construction.
          */
         public int getRecoveredCount()
         {
@@ -111,8 +125,7 @@ public final class ObjectArrayPool exten
         }
 
         /**
-            Returns the number of items this pool has recycled since
-            it's construction.
+         * Returns the number of items this pool has recycled since it's construction.
          */
         public int getRecycledCount()
         {
@@ -130,41 +143,42 @@ public final class ObjectArrayPool exten
         return pools;
     }
 
-    public synchronized SizePool getSizePool(int arraySize)
+    public synchronized SizePool getSizePool( int arraySize )
     {
-        SizePool     result = (SizePool)pools.get(arraySize);
+        SizePool result = (SizePool) pools.get( arraySize );
 
-        if (result == null) {
-            pools.put(arraySize, result = new SizePool(arraySize));
+        if ( result == null )
+        {
+            pools.put( arraySize, result = new SizePool( arraySize ) );
         }
         return result;
     }
 
-    public synchronized Object[] create(int arraySize)
+    public synchronized Object[] create( int arraySize )
     {
-        return getSizePool(arraySize).create();
+        return getSizePool( arraySize ).create();
     }
 
-    public synchronized Object[] create(Object singleton)
+    public synchronized Object[] create( Object singleton )
     {
-        Object[]        result = create(1);
+        Object[] result = create( 1 );
 
         result[0] = singleton;
         return result;
     }
 
-    public synchronized Object[] create(Object object1, Object object2)
+    public synchronized Object[] create( Object object1, Object object2 )
     {
-        Object[]        result = create(2);
+        Object[] result = create( 2 );
 
         result[0] = object1;
         result[1] = object2;
         return result;
     }
 
-    public synchronized Object[] create(Object object1, Object object2, Object object3)
+    public synchronized Object[] create( Object object1, Object object2, Object object3 )
     {
-        Object[]        result = create(3);
+        Object[] result = create( 3 );
 
         result[0] = object1;
         result[1] = object2;
@@ -172,9 +186,9 @@ public final class ObjectArrayPool exten
         return result;
     }
 
-    public synchronized Object[] create(Object object1, Object object2, Object object3, Object object4)
+    public synchronized Object[] create( Object object1, Object object2, Object object3, Object object4 )
     {
-        Object[]        result = create(4);
+        Object[] result = create( 4 );
 
         result[0] = object1;
         result[1] = object2;
@@ -183,9 +197,9 @@ public final class ObjectArrayPool exten
         return result;
     }
 
-    public synchronized Object[] create(Object object1, Object object2, Object object3, Object object4, Object object5)
+    public synchronized Object[] create( Object object1, Object object2, Object object3, Object object4, Object object5 )
     {
-        Object[]        result = create(5);
+        Object[] result = create( 5 );
 
         result[0] = object1;
         result[1] = object2;
@@ -195,10 +209,11 @@ public final class ObjectArrayPool exten
         return result;
     }
 
-    public synchronized void recycle(Object[] value)
+    public synchronized void recycle( Object[] value )
     {
-        if (value != null) {
-            getSizePool(value.length).recycle(value);
+        if ( value != null )
+        {
+            getSizePool( value.length ).recycle( value );
         }
     }
 }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectElementsAccessor.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectElementsAccessor.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectElementsAccessor.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectElementsAccessor.java Sat May 14 13:18:29 2011
@@ -22,33 +22,38 @@ package org.apache.commons.ognl;
 import java.util.*;
 
 /**
- * Implementation of ElementsAccessor that returns a single-element iterator, containing
- * the original target object.
+ * Implementation of ElementsAccessor that returns a single-element iterator, containing the original target object.
+ * 
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-public class ObjectElementsAccessor implements ElementsAccessor
+public class ObjectElementsAccessor
+    implements ElementsAccessor
 {
     public Enumeration getElements( Object target )
     {
-    	final Object		object = target;
+        final Object object = target;
 
-        return new Enumeration() {
-        	private boolean seen = false;
+        return new Enumeration()
+        {
+            private boolean seen = false;
 
-	        public boolean hasMoreElements() {
-	            return !seen;
-	        }
+            public boolean hasMoreElements()
+            {
+                return !seen;
+            }
 
-	        public Object nextElement() {
-	        	Object		result = null;
+            public Object nextElement()
+            {
+                Object result = null;
 
-	        	if (!seen) {
-	        		result = object;
-	        		seen = true;
-	        	}
-	            return result;
-	        }
-	    };
+                if ( !seen )
+                {
+                    result = object;
+                    seen = true;
+                }
+                return result;
+            }
+        };
     }
 }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectIndexedPropertyDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectIndexedPropertyDescriptor.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectIndexedPropertyDescriptor.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectIndexedPropertyDescriptor.java Sat May 14 13:18:29 2011
@@ -23,73 +23,80 @@ import java.beans.*;
 import java.lang.reflect.*;
 
 /**
- * <p>PropertyDescriptor subclass that describes an indexed set of read/write
- * methods to get a property. Unlike IndexedPropertyDescriptor this allows
- * the "key" to be an arbitrary object rather than just an int.  Consequently
- * it does not have a "readMethod" or "writeMethod" because it only expects
- * a pattern like:</p>
- *<pre>
+ * <p>
+ * PropertyDescriptor subclass that describes an indexed set of read/write methods to get a property. Unlike
+ * IndexedPropertyDescriptor this allows the "key" to be an arbitrary object rather than just an int. Consequently it
+ * does not have a "readMethod" or "writeMethod" because it only expects a pattern like:
+ * </p>
+ * 
+ * <pre>
  *    public void set<i>Property</i>(<i>KeyType</i>, <i>ValueType</i>);
  *    public <i>ValueType</i> get<i>Property</i>(<i>KeyType</i>);
- *</pre>
- * <p>and does not require the methods that access it as an array.  OGNL can
- * get away with this without losing functionality because if the object
- * does expose the properties they are most probably in a Map and that case
- * is handled by the normal OGNL property accessors.
- *</p>
- *<p>For example, if an object were to have methods that accessed and "attributes"
- * property it would be natural to index them by String rather than by integer
- * and expose the attributes as a map with a different property name:
- *<pre>
- *    public void setAttribute(String name, Object value);
- *    public Object getAttribute(String name);
- *    public Map getAttributes();
- *</pre>
- *<p>Note that the index get/set is called get/set <code>Attribute</code>
- * whereas the collection getter is called <code>Attributes</code>.  This
- * case is handled unambiguously by the OGNL property accessors because the
- * set/get<code>Attribute</code> methods are detected by this object and the
- * "attributes" case is handled by the <code>MapPropertyAccessor</code>.
- * Therefore OGNL expressions calling this code would be handled in the
- * following way:
- *</p>
- *<table>
- *  <tr><th>OGNL Expression</th>
- *      <th>Handling</th>
- *  </tr>
- *  <tr>
- *      <td><code>attribute["name"]</code></td>
- *      <td>Handled by an index getter, like <code>getAttribute(String)</code>.</td>
- *  </tr>
- *  <tr>
- *      <td><code>attribute["name"] = value</code></td>
- *      <td>Handled by an index setter, like <code>setAttribute(String, Object)</code>.</td>
- *  </tr>
- *  <tr>
- *      <td><code>attributes["name"]</code></td>
- *      <td>Handled by <code>MapPropertyAccessor</code> via a <code>Map.get()</code>.  This
- *          will <b>not</b> go through the index get accessor.
- *      </td>
- *  </tr>
- *  <tr>
- *      <td><code>attributes["name"] = value</code></td>
- *      <td>Handled by <code>MapPropertyAccessor</code> via a <code>Map.put()</code>.  This
- *          will <b>not</b> go through the index set accessor.
- *      </td>
- *  </tr>
+ * </pre>
+ * <p>
+ * and does not require the methods that access it as an array. OGNL can get away with this without losing functionality
+ * because if the object does expose the properties they are most probably in a Map and that case is handled by the
+ * normal OGNL property accessors.
+ * </p>
+ * <p>
+ * For example, if an object were to have methods that accessed and "attributes" property it would be natural to index
+ * them by String rather than by integer and expose the attributes as a map with a different property name:
+ * 
+ * <pre>
+ * public void setAttribute( String name, Object value );
+ * 
+ * public Object getAttribute( String name );
+ * 
+ * public Map getAttributes();
+ * </pre>
+ * <p>
+ * Note that the index get/set is called get/set <code>Attribute</code> whereas the collection getter is called
+ * <code>Attributes</code>. This case is handled unambiguously by the OGNL property accessors because the set/get
+ * <code>Attribute</code> methods are detected by this object and the "attributes" case is handled by the
+ * <code>MapPropertyAccessor</code>. Therefore OGNL expressions calling this code would be handled in the following way:
+ * </p>
+ * <table>
+ * <tr>
+ * <th>OGNL Expression</th>
+ * <th>Handling</th>
+ * </tr>
+ * <tr>
+ * <td><code>attribute["name"]</code></td>
+ * <td>Handled by an index getter, like <code>getAttribute(String)</code>.</td>
+ * </tr>
+ * <tr>
+ * <td><code>attribute["name"] = value</code></td>
+ * <td>Handled by an index setter, like <code>setAttribute(String, Object)</code>.</td>
+ * </tr>
+ * <tr>
+ * <td><code>attributes["name"]</code></td>
+ * <td>Handled by <code>MapPropertyAccessor</code> via a <code>Map.get()</code>. This will <b>not</b> go through the
+ * index get accessor.</td>
+ * </tr>
+ * <tr>
+ * <td><code>attributes["name"] = value</code></td>
+ * <td>Handled by <code>MapPropertyAccessor</code> via a <code>Map.put()</code>. This will <b>not</b> go through the
+ * index set accessor.</td>
+ * </tr>
  * </table>
+ * 
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-public class ObjectIndexedPropertyDescriptor extends PropertyDescriptor
+public class ObjectIndexedPropertyDescriptor
+    extends PropertyDescriptor
 {
-    private Method          indexedReadMethod;
-    private Method          indexedWriteMethod;
-    private Class           propertyType;
+    private Method indexedReadMethod;
 
-    public ObjectIndexedPropertyDescriptor(String propertyName, Class propertyType, Method indexedReadMethod, Method indexedWriteMethod) throws IntrospectionException
+    private Method indexedWriteMethod;
+
+    private Class propertyType;
+
+    public ObjectIndexedPropertyDescriptor( String propertyName, Class propertyType, Method indexedReadMethod,
+                                            Method indexedWriteMethod )
+        throws IntrospectionException
     {
-        super(propertyName, null, null);
+        super( propertyName, null, null );
         this.propertyType = propertyType;
         this.indexedReadMethod = indexedReadMethod;
         this.indexedWriteMethod = indexedWriteMethod;

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectMethodAccessor.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectMethodAccessor.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectMethodAccessor.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectMethodAccessor.java Sat May 14 13:18:29 2011
@@ -23,38 +23,39 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * Implementation of PropertyAccessor that uses reflection on the target object's class to find a
- * field or a pair of set/get methods with the given property name.
- *
+ * Implementation of PropertyAccessor that uses reflection on the target object's class to find a field or a pair of
+ * set/get methods with the given property name.
+ * 
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-public class ObjectMethodAccessor implements MethodAccessor
+public class ObjectMethodAccessor
+    implements MethodAccessor
 {
 
     /* MethodAccessor interface */
-    public Object callStaticMethod(Map context, Class targetClass, String methodName, Object[] args)
-            throws MethodFailedException
+    public Object callStaticMethod( Map context, Class targetClass, String methodName, Object[] args )
+        throws MethodFailedException
     {
-        List methods = OgnlRuntime.getMethods(targetClass, methodName, true);
+        List methods = OgnlRuntime.getMethods( targetClass, methodName, true );
 
-        return OgnlRuntime.callAppropriateMethod((OgnlContext) context, targetClass,
-                                                 null, methodName, null, methods, args);
+        return OgnlRuntime.callAppropriateMethod( (OgnlContext) context, targetClass, null, methodName, null, methods,
+                                                  args );
     }
 
-    public Object callMethod(Map context, Object target, String methodName, Object[] args)
-            throws MethodFailedException
+    public Object callMethod( Map context, Object target, String methodName, Object[] args )
+        throws MethodFailedException
     {
-        Class targetClass = (target == null) ? null : target.getClass();
-        List methods = OgnlRuntime.getMethods(targetClass, methodName, false);
+        Class targetClass = ( target == null ) ? null : target.getClass();
+        List methods = OgnlRuntime.getMethods( targetClass, methodName, false );
 
-        if ((methods == null) || (methods.size() == 0))
+        if ( ( methods == null ) || ( methods.size() == 0 ) )
         {
-            methods = OgnlRuntime.getMethods(targetClass, methodName, true);
+            methods = OgnlRuntime.getMethods( targetClass, methodName, true );
 
         }
 
-        return OgnlRuntime.callAppropriateMethod((OgnlContext) context, target,
-                                                 target, methodName, null, methods, args);
+        return OgnlRuntime.callAppropriateMethod( (OgnlContext) context, target, target, methodName, null, methods,
+                                                  args );
     }
 }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectNullHandler.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectNullHandler.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectNullHandler.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectNullHandler.java Sat May 14 13:18:29 2011
@@ -22,20 +22,22 @@ package org.apache.commons.ognl;
 import java.util.*;
 
 /**
- * Implementation of NullHandler that returns null in all cases,
- * so that NullPointerException will be thrown by the caller.
+ * Implementation of NullHandler that returns null in all cases, so that NullPointerException will be thrown by the
+ * caller.
+ * 
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-public class ObjectNullHandler implements NullHandler
+public class ObjectNullHandler
+    implements NullHandler
 {
     /* NullHandler interface */
-    public Object nullMethodResult(Map context, Object target, String methodName, Object[] args)
+    public Object nullMethodResult( Map context, Object target, String methodName, Object[] args )
     {
         return null;
     }
 
-    public Object nullPropertyValue(Map context, Object target, Object property)
+    public Object nullPropertyValue( Map context, Object target, Object property )
     {
         return null;
     }

Modified: incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectPropertyAccessor.java
URL: http://svn.apache.org/viewvc/incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectPropertyAccessor.java?rev=1103095&r1=1103094&r2=1103095&view=diff
==============================================================================
--- incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectPropertyAccessor.java (original)
+++ incubator/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectPropertyAccessor.java Sat May 14 13:18:29 2011
@@ -28,34 +28,43 @@ import java.lang.reflect.Method;
 import java.util.Map;
 
 /**
- * Implementation of PropertyAccessor that uses reflection on the target object's class to find a
- * field or a pair of set/get methods with the given property name.
- *
+ * Implementation of PropertyAccessor that uses reflection on the target object's class to find a field or a pair of
+ * set/get methods with the given property name.
+ * 
  * @author Luke Blanshard (blanshlu@netscape.net)
  * @author Drew Davidson (drew@ognl.org)
  */
-public class ObjectPropertyAccessor implements PropertyAccessor {
+public class ObjectPropertyAccessor
+    implements PropertyAccessor
+{
 
     /**
      * Returns OgnlRuntime.NotFound if the property does not exist.
      */
-    public Object getPossibleProperty(Map context, Object target, String name)
-            throws OgnlException
+    public Object getPossibleProperty( Map context, Object target, String name )
+        throws OgnlException
     {
         Object result;
         OgnlContext ognlContext = (OgnlContext) context;
 
-        try {
-            if ((result = OgnlRuntime.getMethodValue(ognlContext, target, name, true)) == OgnlRuntime.NotFound)
+        try
+        {
+            if ( ( result = OgnlRuntime.getMethodValue( ognlContext, target, name, true ) ) == OgnlRuntime.NotFound )
             {
-                result = OgnlRuntime.getFieldValue(ognlContext, target, name, true);
+                result = OgnlRuntime.getFieldValue( ognlContext, target, name, true );
             }
-        } catch (IntrospectionException ex) {
-            throw new OgnlException(name, ex);
-        } catch (OgnlException ex) {
+        }
+        catch ( IntrospectionException ex )
+        {
+            throw new OgnlException( name, ex );
+        }
+        catch ( OgnlException ex )
+        {
             throw ex;
-        } catch (Exception ex) {
-            throw new OgnlException(name, ex);
+        }
+        catch ( Exception ex )
+        {
+            throw new OgnlException( name, ex );
         }
 
         return result;
@@ -64,114 +73,134 @@ public class ObjectPropertyAccessor impl
     /**
      * Returns OgnlRuntime.NotFound if the property does not exist.
      */
-    public Object setPossibleProperty(Map context, Object target, String name, Object value)
-            throws OgnlException
+    public Object setPossibleProperty( Map context, Object target, String name, Object value )
+        throws OgnlException
     {
         Object result = null;
         OgnlContext ognlContext = (OgnlContext) context;
 
-        try {
-            if (!OgnlRuntime.setMethodValue(ognlContext, target, name, value, true))
+        try
+        {
+            if ( !OgnlRuntime.setMethodValue( ognlContext, target, name, value, true ) )
             {
-                result = OgnlRuntime.setFieldValue(ognlContext, target, name, value) ? null : OgnlRuntime.NotFound;
+                result = OgnlRuntime.setFieldValue( ognlContext, target, name, value ) ? null : OgnlRuntime.NotFound;
             }
 
-            if (result == OgnlRuntime.NotFound)
+            if ( result == OgnlRuntime.NotFound )
             {
-                Method m = OgnlRuntime.getWriteMethod(target.getClass(), name);
-                if (m != null)
+                Method m = OgnlRuntime.getWriteMethod( target.getClass(), name );
+                if ( m != null )
                 {
-                    result = m.invoke(target, new Object[] { value});
+                    result = m.invoke( target, new Object[] { value } );
                 }
             }
-        } catch (IntrospectionException ex) {
-            throw new OgnlException(name, ex);
-        } catch (OgnlException ex) {
+        }
+        catch ( IntrospectionException ex )
+        {
+            throw new OgnlException( name, ex );
+        }
+        catch ( OgnlException ex )
+        {
             throw ex;
-        } catch (Exception ex) {
-            throw new OgnlException(name, ex);
+        }
+        catch ( Exception ex )
+        {
+            throw new OgnlException( name, ex );
         }
 
         return result;
     }
 
-    public boolean hasGetProperty(OgnlContext context, Object target, Object oname)
-            throws OgnlException
+    public boolean hasGetProperty( OgnlContext context, Object target, Object oname )
+        throws OgnlException
     {
-        try {
-            return OgnlRuntime.hasGetProperty(context, target, oname);
-        } catch (IntrospectionException ex) {
-            throw new OgnlException("checking if " + target + " has gettable property " + oname, ex);
+        try
+        {
+            return OgnlRuntime.hasGetProperty( context, target, oname );
+        }
+        catch ( IntrospectionException ex )
+        {
+            throw new OgnlException( "checking if " + target + " has gettable property " + oname, ex );
         }
     }
 
-    public boolean hasGetProperty(Map context, Object target, Object oname)
-            throws OgnlException
+    public boolean hasGetProperty( Map context, Object target, Object oname )
+        throws OgnlException
     {
-        return hasGetProperty((OgnlContext) context, target, oname);
+        return hasGetProperty( (OgnlContext) context, target, oname );
     }
 
-    public boolean hasSetProperty(OgnlContext context, Object target, Object oname)
-            throws OgnlException
+    public boolean hasSetProperty( OgnlContext context, Object target, Object oname )
+        throws OgnlException
     {
-        try {
-            return OgnlRuntime.hasSetProperty(context, target, oname);
-        } catch (IntrospectionException ex) {
-            throw new OgnlException("checking if " + target + " has settable property " + oname, ex);
+        try
+        {
+            return OgnlRuntime.hasSetProperty( context, target, oname );
+        }
+        catch ( IntrospectionException ex )
+        {
+            throw new OgnlException( "checking if " + target + " has settable property " + oname, ex );
         }
     }
 
-    public boolean hasSetProperty(Map context, Object target, Object oname)
-            throws OgnlException
+    public boolean hasSetProperty( Map context, Object target, Object oname )
+        throws OgnlException
     {
-        return hasSetProperty((OgnlContext) context, target, oname);
+        return hasSetProperty( (OgnlContext) context, target, oname );
     }
 
-    public Object getProperty(Map context, Object target, Object oname)
-            throws OgnlException
+    public Object getProperty( Map context, Object target, Object oname )
+        throws OgnlException
     {
         Object result = null;
         String name = oname.toString();
 
-        result = getPossibleProperty(context, target, name);
+        result = getPossibleProperty( context, target, name );
 
-        if (result == OgnlRuntime.NotFound)
+        if ( result == OgnlRuntime.NotFound )
         {
-            throw new NoSuchPropertyException(target, name);
+            throw new NoSuchPropertyException( target, name );
         }
 
         return result;
     }
 
-    public void setProperty(Map context, Object target, Object oname, Object value)
-            throws OgnlException
+    public void setProperty( Map context, Object target, Object oname, Object value )
+        throws OgnlException
     {
         String name = oname.toString();
 
-        Object result = setPossibleProperty(context, target, name, value);
+        Object result = setPossibleProperty( context, target, name, value );
 
-        if (result == OgnlRuntime.NotFound)
+        if ( result == OgnlRuntime.NotFound )
         {
-            throw new NoSuchPropertyException(target, name);
+            throw new NoSuchPropertyException( target, name );
         }
     }
 
-    public Class getPropertyClass(OgnlContext context, Object target, Object index)
+    public Class getPropertyClass( OgnlContext context, Object target, Object index )
     {
-        try {
-            Method m = OgnlRuntime.getReadMethod(target.getClass(), index.toString());
+        try
+        {
+            Method m = OgnlRuntime.getReadMethod( target.getClass(), index.toString() );
 
-            if (m == null) {
+            if ( m == null )
+            {
 
-                if (String.class.isAssignableFrom(index.getClass()) && !target.getClass().isArray()) {
-                    String key = ((String) index).replaceAll("\"", "");
-                    try {
-                        Field f = target.getClass().getField(key);
-                        if (f != null) {
+                if ( String.class.isAssignableFrom( index.getClass() ) && !target.getClass().isArray() )
+                {
+                    String key = ( (String) index ).replaceAll( "\"", "" );
+                    try
+                    {
+                        Field f = target.getClass().getField( key );
+                        if ( f != null )
+                        {
 
                             return f.getType();
                         }
-                    } catch (NoSuchFieldException e) {
+                    }
+                    catch ( NoSuchFieldException e )
+                    {
                         return null;
                     }
                 }
@@ -181,118 +210,138 @@ public class ObjectPropertyAccessor impl
 
             return m.getReturnType();
 
-        } catch (Throwable t)
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
     }
 
-    public String getSourceAccessor(OgnlContext context, Object target, Object index)
+    public String getSourceAccessor( OgnlContext context, Object target, Object index )
     {
-        try {
+        try
+        {
 
-            String methodName = index.toString().replaceAll("\"", "");
-            Method m = OgnlRuntime.getReadMethod(target.getClass(), methodName);
+            String methodName = index.toString().replaceAll( "\"", "" );
+            Method m = OgnlRuntime.getReadMethod( target.getClass(), methodName );
 
             // try last ditch effort of checking if they were trying to do reflection via a return method value
 
-            if (m == null && context.getCurrentObject() != null)
-                m = OgnlRuntime.getReadMethod(target.getClass(), context.getCurrentObject().toString().replaceAll("\"", ""));
+            if ( m == null && context.getCurrentObject() != null )
+                m =
+                    OgnlRuntime.getReadMethod( target.getClass(),
+                                               context.getCurrentObject().toString().replaceAll( "\"", "" ) );
 
-            //System.out.println("tried to get read method from target: " + target.getClass() + " with methodName:" + methodName + " result: " + m);
+            // System.out.println("tried to get read method from target: " + target.getClass() + " with methodName:" +
+            // methodName + " result: " + m);
             // try to get field if no method could be found
 
-            if (m == null)
+            if ( m == null )
             {
                 try
                 {
-                    if (String.class.isAssignableFrom(index.getClass()) && !target.getClass().isArray())
+                    if ( String.class.isAssignableFrom( index.getClass() ) && !target.getClass().isArray() )
                     {
-                        Field f = target.getClass().getField(methodName);
+                        Field f = target.getClass().getField( methodName );
 
-                        if (f != null)
+                        if ( f != null )
                         {
-                            context.setCurrentType(f.getType());
-                            context.setCurrentAccessor(f.getDeclaringClass());
+                            context.setCurrentType( f.getType() );
+                            context.setCurrentAccessor( f.getDeclaringClass() );
 
                             return "." + f.getName();
                         }
                     }
                 }
-                catch (NoSuchFieldException e) {
+                catch ( NoSuchFieldException e )
+                {
                     // ignore
                 }
 
                 return "";
             }
 
-            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 "." + m.getName() + "()";
 
-        } catch (Throwable t)
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
     }
 
-    public String getSourceSetter(OgnlContext context, Object target, Object index)
+    public String getSourceSetter( OgnlContext context, Object target, Object index )
     {
-        try {
+        try
+        {
 
-            String methodName = index.toString().replaceAll("\"", "");
-            Method m = OgnlRuntime.getWriteMethod(target.getClass(), methodName);
+            String methodName = index.toString().replaceAll( "\"", "" );
+            Method m = OgnlRuntime.getWriteMethod( target.getClass(), methodName );
 
-            if (m == null && context.getCurrentObject() != null
-                && context.getCurrentObject().toString() != null)
+            if ( m == null && context.getCurrentObject() != null && context.getCurrentObject().toString() != null )
             {
-                m = OgnlRuntime.getWriteMethod(target.getClass(), context.getCurrentObject().toString().replaceAll("\"", ""));
+                m =
+                    OgnlRuntime.getWriteMethod( target.getClass(),
+                                                context.getCurrentObject().toString().replaceAll( "\"", "" ) );
             }
 
-            if (m == null || m.getParameterTypes() == null || m.getParameterTypes().length <= 0)
-                throw new UnsupportedCompilationException("Unable to determine setting expression on " + context.getCurrentObject()
-                                                          + " with index of " + index);
+            if ( m == null || m.getParameterTypes() == null || m.getParameterTypes().length <= 0 )
+                throw new UnsupportedCompilationException( "Unable to determine setting expression on "
+                    + context.getCurrentObject() + " with index of " + index );
 
             Class parm = m.getParameterTypes()[0];
             String conversion;
 
-            if (m.getParameterTypes().length > 1)
-                throw new UnsupportedCompilationException("Object property accessors can only support single parameter setters.");
+            if ( m.getParameterTypes().length > 1 )
+                throw new UnsupportedCompilationException(
+                                                           "Object property accessors can only support single parameter setters." );
 
-
-            if (parm.isPrimitive())
+            if ( parm.isPrimitive() )
             {
-                Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(parm);
-                conversion = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                            "((" + wrapClass.getName() + ")org.apache.commons.ognl.OgnlOps#convertValue($3," + wrapClass.getName()
-                                                                            + ".class, true))." + OgnlRuntime.getNumericValueGetter(wrapClass),
-                                                                            parm);
+                Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass( parm );
+                conversion =
+                    OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                    "(("
+                                                                        + wrapClass.getName()
+                                                                        + ")org.apache.commons.ognl.OgnlOps#convertValue($3,"
+                                                                        + wrapClass.getName() + ".class, true))."
+                                                                        + OgnlRuntime.getNumericValueGetter( wrapClass ),
+                                                                    parm );
 
-            } else if (parm.isArray())
+            }
+            else if ( parm.isArray() )
             {
-                conversion = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                            "(" + ExpressionCompiler.getCastString(parm) + ")org.apache.commons.ognl.OgnlOps#toArray($3,"
-                                                                            + parm.getComponentType().getName() + ".class)",
-                                                                            parm);
+                conversion =
+                    OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                    "("
+                                                                        + ExpressionCompiler.getCastString( parm )
+                                                                        + ")org.apache.commons.ognl.OgnlOps#toArray($3,"
+                                                                        + parm.getComponentType().getName() + ".class)",
+                                                                    parm );
 
-            } else
+            }
+            else
             {
-                conversion = OgnlRuntime.getCompiler().createLocalReference(context,
-                                                                            "(" + parm.getName()+ ")org.apache.commons.ognl.OgnlOps#convertValue($3,"
-                                                                            + parm.getName()
-                                                                            + ".class)",
-                                                                            parm);
+                conversion =
+                    OgnlRuntime.getCompiler().createLocalReference( context,
+                                                                    "("
+                                                                        + parm.getName()
+                                                                        + ")org.apache.commons.ognl.OgnlOps#convertValue($3,"
+                                                                        + parm.getName() + ".class)", parm );
             }
 
-            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 "." + m.getName() + "(" + conversion + ")";
 
-        } catch (Throwable t)
+        }
+        catch ( Throwable t )
         {
-            throw OgnlOps.castToRuntime(t);
+            throw OgnlOps.castToRuntime( t );
         }
     }
 }