commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Biestro (JIRA)" <>
Subject [jira] [Resolved] (JEXL-222) The ability to declare indexed property getter/setter in customised JexlArithmetic implementation
Date Tue, 14 Mar 2017 14:10:41 GMT


Henri Biestro resolved JEXL-222.
       Resolution: Fixed
    Fix Version/s: 3.1

The current overload code already allows this. To help ensure that the overload is applied
to the desired containers, IndexedType.IndexedContainer exposes new methods exposing the name
& class.
One can thus implement the following in a derived JexlArithmetic:
...        public Object propertySet(IndexedType.IndexedContainer map, String key, Integer
value) {
            if (map.getContainerClass().equals(PropertyContainer.class)
                && map.getContainerName().equals("property")) {
                try {
                    map.set(key, value.toString());
                } catch (Exception xany) {
                    throw new JexlException.Operator(null, key + "." + value.toString(), xany);
                return null;
            return JexlEngine.TRY_FAILED;


Committed revision 1786904.

> The ability to declare indexed property getter/setter in customised JexlArithmetic implementation
> -------------------------------------------------------------------------------------------------
>                 Key: JEXL-222
>                 URL:
>             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 method in customized
JexlArithmetic class that will be used by Jexl engine when engine tries to get access to a
property of some object. This is great extension point of the Jexl but I have come to a situation
where I need the same 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} = "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 solution 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

View raw message