You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Pierre Brico <pi...@gmail.com> on 2008/05/31 23:05:02 UTC

JEXL expression with array

Hi all,

I'm new with JEXL and I have a question with the usage of array. I'm
building a complex HashMap structure (which can contain other HashMap) to
evaluate several expressions. When building the HashMap, if a node contains
more than one variable with the same name, I transform it into a ArrayList
to be able to access each element. Here is an exemple:

a.b.c = 1
a.b.d = 2
a.b.d = 3
a.c = 4

This will be something like:

X = HashMap(("c", 1), ("d", ArrayList(2 ,3)));
Y = HashMap(("b", X), ("c", 4));
HashMap(("a", Y));

My question is: As I don't know in advance if a item is a ArrayList or a
HashMap, I would like that expression like "a.b.d" returns 2 (the first
item) or expression like "a.b.c[0]" returns 1.

Is it possible ??

Thx
Pierre