Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 619B1200C38 for ; Wed, 15 Mar 2017 09:52:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 60647160B8A; Wed, 15 Mar 2017 08:52:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B1A8D160B70 for ; Wed, 15 Mar 2017 09:52:45 +0100 (CET) Received: (qmail 35896 invoked by uid 500); 15 Mar 2017 08:52:44 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 35875 invoked by uid 99); 15 Mar 2017 08:52:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Mar 2017 08:52:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 9FBF7180993 for ; Wed, 15 Mar 2017 08:52:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.451 X-Spam-Level: * X-Spam-Status: No, score=1.451 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id NHQmJtfLGlsS for ; Wed, 15 Mar 2017 08:52:42 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 5591F5F238 for ; Wed, 15 Mar 2017 08:52:42 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D63A3E05BF for ; Wed, 15 Mar 2017 08:52:41 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 89711243A6 for ; Wed, 15 Mar 2017 08:52:41 +0000 (UTC) Date: Wed, 15 Mar 2017 08:52:41 +0000 (UTC) From: "Dmitri Blinov (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (JEXL-222) The ability to declare indexed property getter/setter in customised JexlArithmetic implementation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 15 Mar 2017 08:52:46 -0000 [ https://issues.apache.org/jira/browse/JEXL-222?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D159257= 64#comment-15925764 ]=20 Dmitri Blinov commented on JEXL-222: ------------------------------------ It has worked for me with the following code:=20 {code} ... public Object propertySet(IndexedType.IndexedContainer map, Stri= ng key, Integer value) { if (PropertyContainer.class.isAssignableFrom(map.getContainerCl= ass()) && map.getContainerName().equals("property")) { try { map.set(key, value.toString()); } catch (Exception xany) { throw new JexlException.Operator(null, map.getContainer= Class() + "." + key, xany); } return null; } return JexlEngine.TRY_FAILED; } ... {code} Great work, thanks! > The ability to declare indexed property getter/setter in customised JexlA= rithmetic implementation > -------------------------------------------------------------------------= ------------------------ > > Key: JEXL-222 > URL: https://issues.apache.org/jira/browse/JEXL-222 > Project: Commons JEXL > Issue Type: Improvement > Affects Versions: 3.0 > Reporter: Dmitri Blinov > Assignee: Henri Biestro > Priority: Minor > Fix For: 3.1 > > > At the moment we have the ability to declare a specific getter/setter met= hod in customized JexlArithmetic class that will be used by Jexl engine whe= n engine tries to get access to a property of some object. This is great ex= tension point of the Jexl but I have come to a situation where I need the s= ame technics to be applied to indexed properties. For example I'm scripting= org.w3c.dom.Element object by setting its attributes via its {code}Element= .setAttribute(java.lang.String name, java.lang.String value) {code} method.= In Jexl I use standard indexed property access syntax like the following: = {code} node.attribute.id =3D "12345"; {code} The problem lies with the last= argument of the setAttribute method which is of String class. And for Jexl= standard indexed property setter to work I should always remember that in = script I need to cast specified property value to a string, which is error-= prone and lacks, in my understanding, scripting easiness. I see the solutio= n as to introduce custom indexed property setter in more generalized form, = accepting Object type as a value so it could cast a value to String before = calling {{Element.setAttribute}} -- This message was sent by Atlassian JIRA (v6.3.15#6346)