Hello Dion,
I have nested HashMap containing the following values:
a.b.c = 1
a.b.d = 2
a.b.d = 3
a.c = 4
To understand better, here is the java code to construct such a structure:
ArrayList A = new ArrayList();
HashMap X = new HashMap();
HashMap Y = new HashMap();
HashMap result = new HashMap();
A.add(2);
A.add(3);
X.put("c", 1);
X.put("d", A);
Y.put("b", X);
Y.put("c", 4);
result.put("a", Y);
Now, using the "result" HashMap, I want to evaluate expressions like:
"a.b.d" should return 2 (the problem is that d is an array)
"a.b.c[0]" should return 1 (the problem is that c isn't an array).
Is this possible ?
Thanks,
Pierre
On Tue, Jun 3, 2008 at 2:09 AM, Dion Gillard <dion@trongus.com> wrote:
> I'm not sure I understand what you're asking here.
>
> So you have the following statements in JEXL:
>
> a.b.c = 1
> a.b.d = 2
> a.b.d = 3
> a.c = 4
>
> Is that right?
>
>
> And you want to know if you can make:
>
> "a.b.d" return 2 and "a.b.c[0]" return 1?
>
>
>
> On Tue, Jun 3, 2008 at 5:06 AM, Pierre Brico <pierre.brico@gmail.com>
> wrote:
> > 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 ? Is there any parameters for JEXL evaluator ?
> >
> > Thx
> > Pierre
> >
>
>
>
> 
> dIon Gillard
> There are only two kinds of programming languages: those people always
> bitch about and those nobody uses. (Bjarne Stroustrup)
>
> 
> To unsubscribe, email: userunsubscribe@commons.apache.org
> For additional commands, email: userhelp@commons.apache.org
>
>
