Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 48510 invoked from network); 3 Jun 2008 07:47:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Jun 2008 07:47:45 -0000 Received: (qmail 68472 invoked by uid 500); 3 Jun 2008 07:47:46 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 67432 invoked by uid 500); 3 Jun 2008 07:47:44 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 67421 invoked by uid 99); 3 Jun 2008 07:47:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jun 2008 00:47:44 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of pierre.brico@gmail.com designates 209.85.198.247 as permitted sender) Received: from [209.85.198.247] (HELO rv-out-0708.google.com) (209.85.198.247) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jun 2008 07:46:55 +0000 Received: by rv-out-0708.google.com with SMTP id k29so1629161rvb.30 for ; Tue, 03 Jun 2008 00:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; bh=J1Gbhe1dxD8OdQwItQbffXZxzmMh48dxAgpw/WKs3Bs=; b=SshmuTMxS+MjRKdISuacoTMl3a3PRdYIgnHy905vPrbdPhhzs8iTIViIOmXBJebW1Lw/KPwTZkKUMfAqz15WgIfkiW3Wq3WtB2DhSRF3fUBYqOGiEVtcfYuH5h383qLj2bPlwbQ5BB9UOyFFBNbDAKRbIQI3lyj65F8dG84sTZs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=NVo1E4vR6dYmfPuTGS3QaeUZ4gYdvHih0RKkYUDLEMzl5Rj5F0VUNyQVkDFJ4H0Mu9bx8Lx1RKHIBkmG2Dl3UOM8b2RQuZq4kByMxVdWY3OAnXayCrZAJ2S/SbJv/QSlPg2jfP0HzMro9AX9736T/eX1z2dwzVlC1+MjE4aqL98= Received: by 10.140.208.17 with SMTP id f17mr5545576rvg.218.1212479232127; Tue, 03 Jun 2008 00:47:12 -0700 (PDT) Received: by 10.140.133.17 with HTTP; Tue, 3 Jun 2008 00:47:12 -0700 (PDT) Message-ID: Date: Tue, 3 Jun 2008 09:47:12 +0200 From: "Pierre Brico" Sender: pierre.brico@gmail.com To: "Commons Users List" Subject: Re: JEXL expression with array In-Reply-To: <935068bf0806021709p49b1dd50xaf3e2315006f2f23@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_24494_8396018.1212479232102" References: <935068bf0806021709p49b1dd50xaf3e2315006f2f23@mail.gmail.com> X-Google-Sender-Auth: 15b776516f753930 X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_24494_8396018.1212479232102 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 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 > 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, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > ------=_Part_24494_8396018.1212479232102--