Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B75FA9A60 for ; Sat, 29 Oct 2011 05:44:45 +0000 (UTC) Received: (qmail 23230 invoked by uid 500); 29 Oct 2011 05:44:45 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 23081 invoked by uid 500); 29 Oct 2011 05:44:36 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 23065 invoked by uid 99); 29 Oct 2011 05:44:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Oct 2011 05:44:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Oct 2011 05:44:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7591423889FA for ; Sat, 29 Oct 2011 05:44:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1190758 - /commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java Date: Sat, 29 Oct 2011 05:44:09 -0000 To: commits@commons.apache.org From: mcucchiara@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111029054409.7591423889FA@eris.apache.org> Author: mcucchiara Date: Sat Oct 29 05:44:09 2011 New Revision: 1190758 URL: http://svn.apache.org/viewvc?rev=1190758&view=rev Log: OGNL-31 - CPD fix to ASTProperty (contributed by Adrian Cumiskey) Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java?rev=1190758&r1=1190757&r2=1190758&view=diff ============================================================================== --- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java (original) +++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTProperty.java Sat Oct 29 05:44:09 2011 @@ -254,32 +254,7 @@ public class ASTProperty String name = ( (ASTConst) _children[0] ).getValue().toString(); - if ( !Iterator.class.isAssignableFrom( context.getCurrentObject().getClass() ) - || ( Iterator.class.isAssignableFrom( context.getCurrentObject().getClass() ) - && name.indexOf( "next" ) < 0 ) ) - { - Object currObj = target; - - try - { - target = getValue( context, context.getCurrentObject() ); - } - catch ( NoSuchPropertyException e ) - { - try - { - target = getValue( context, context.getRoot() ); - } - catch ( NoSuchPropertyException ex ) - { - // ignore - } - } - finally - { - context.setCurrentObject( currObj ); - } - } + target = getTarget( context, target, name ); PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor( context.getCurrentObject().getClass(), name ); @@ -411,6 +386,39 @@ public class ASTProperty return result; } + Object getTarget( OgnlContext context, Object target, String name ) + throws OgnlException + { + Class clazz = context.getCurrentObject().getClass(); + if ( !Iterator.class.isAssignableFrom(clazz) + || ( Iterator.class.isAssignableFrom(clazz) + && name.indexOf( "next" ) < 0 ) ) + { + Object currObj = target; + + try + { + target = getValue( context, context.getCurrentObject() ); + } + catch ( NoSuchPropertyException e ) + { + try + { + target = getValue( context, context.getRoot() ); + } + catch ( NoSuchPropertyException ex ) + { + // ignore + } + } + finally + { + context.setCurrentObject( currObj ); + } + } + return target; + } + Method getIndexedWriteMethod( PropertyDescriptor pd ) { if ( IndexedPropertyDescriptor.class.isInstance( pd ) ) @@ -565,36 +573,7 @@ public class ASTProperty // System.out.println(" astprop(setter) : trying to set " + name + " on object target " + // context.getCurrentObject().getClass().getName()); - if ( !Iterator.class.isAssignableFrom( context.getCurrentObject().getClass() ) - || ( Iterator.class.isAssignableFrom( context.getCurrentObject().getClass() ) - && name.indexOf( "next" ) < 0 ) ) - { - - Object currObj = target; - - try - { - target = getValue( context, context.getCurrentObject() ); - } - catch ( NoSuchPropertyException e ) - { - try - { - - target = getValue( context, context.getRoot() ); - - } - catch ( NoSuchPropertyException ex ) - { - // TODO: how to handle this accordingly? - } - } - finally - { - - context.setCurrentObject( currObj ); - } - } + target = getTarget( context, target, name ); PropertyDescriptor pd = OgnlRuntime.getPropertyDescriptor(