Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 81485 invoked from network); 30 Nov 2008 22:20:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Nov 2008 22:20:11 -0000 Received: (qmail 88068 invoked by uid 500); 30 Nov 2008 22:20:19 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 88001 invoked by uid 500); 30 Nov 2008 22:20:19 -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 87990 invoked by uid 99); 30 Nov 2008 22:20:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Nov 2008 14:20:19 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ahhughes@gmail.com designates 209.85.142.184 as permitted sender) Received: from [209.85.142.184] (HELO ti-out-0910.google.com) (209.85.142.184) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Nov 2008 22:18:51 +0000 Received: by ti-out-0910.google.com with SMTP id u5so1446315tia.10 for ; Sun, 30 Nov 2008 14:19:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=bAwO67KWiRy011RhEqpVdn8iApQMbRyvTs8eR4osvKc=; b=sFX4jf+F/HqgNJtbpWg7eYI0i2Mupr0D5wyOIWKLO3JOR0b0N2yr2ASKk5fEjeD7aB GV7Nvb5d8dlyplsD6nEpKG6hIiKeRF8mgqdgcPHaY4ijHktw+EdrOmG467SvyS+ZiF7u PTfj4AFl+YMsawvmAXbLuQ4ikoPXoPXFYoQDA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=o+O81ArFm3SeS9k3X/ztFP02GuOsPUOk/i0l//Cx55yVqsLyUsefmOm3XBFCjPOIYz brzU94mLncemkgBzfnnT2BMUz12VaZtNo8CpI3zBO+R3BvakHsUxFGnspy8upRhrxs/2 ionSauMGL9CrxVIbePlMeMd4lFQMLHsGEvUB4= Received: by 10.110.63.17 with SMTP id l17mr811836tia.23.1228083577642; Sun, 30 Nov 2008 14:19:37 -0800 (PST) Received: by 10.110.60.8 with HTTP; Sun, 30 Nov 2008 14:19:37 -0800 (PST) Message-ID: <5f528cf40811301419y7482947dqd7c6a51e724cd0ed@mail.gmail.com> Date: Mon, 1 Dec 2008 08:49:37 +1030 From: "Andrew Hughes" To: "Commons Users List" Subject: Re: JXPath XBeanInfo & Generic Collection Problem In-Reply-To: <5f528cf40811241635o70f99a21kc37eaff1bffd9780@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_18194_33148752.1228083577635" References: <5f528cf40811201912w45483968n82ad388d02989047@mail.gmail.com> <5f528cf40811231519v5e45d176i269ef91d27690fba@mail.gmail.com> <5f528cf40811231758g4009528bl8049fb0f6d407b37@mail.gmail.com> <5f528cf40811241635o70f99a21kc37eaff1bffd9780@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_18194_33148752.1228083577635 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Does JXPath still have an active user/development base? I've seen very little traffic on this list. This still does not work and I've no idea why. On Tue, Nov 25, 2008 at 11:05 AM, Andrew Hughes wrote: > Everything falls apart once collections or array's are involved. I am doing > something wrong, help would be most appreciated. I can't see any simple > examples online and there's no doco on how to do this. > I'm considering giving up, like the rest of the people before me. > > On Mon, Nov 24, 2008 at 12:28 PM, Andrew Hughes wrote: > >> After further testing, I have reduced the complexity of my 'Bean'. The >> 'Bean' is no longer a Collection<> and provides getThe* methods that do not >> meet the Beans standard. Hence, JXPath must use an XBeanInfo and >> DynamicHandler to perform sucessful traversal/evalution, and it does... >> For the first time I can see DynamicHandler being called. My >> previous DynamicHandler that worked with a Collection class was never >> initialized and thus proves JXPath was never using it. >> >> The big question is, why? I know I can get around this by reworking my >> datastructure so that it does not extend ArrayList () but I really >> don't think I should have to do this. >> >> I've read a few posts with the same problem now (some as far back as >> 2006). Im yet to see a solution, it looks like everyone else just decides to >> 'give up' which I'd rather not do, because if this works it's a great >> solution. >> >> :) >> >> >> On Mon, Nov 24, 2008 at 9:49 AM, Andrew Hughes wrote: >> >>> After a little more investigation, I have overriden every >>> Collection/ArrayList method in the "PojoNode" class to see how/if JXPath >>> calls ANY of the inherited super methods. It does not! If JXPath is not >>> traversing my data structure in any way, then it's probably not even >>> evaluating it. But Im not sure why this would be, or why under such >>> circumstances a mis-configuration like this does not throw any exceptions. >>> As I said, I think I have exhausted the online docs and I'm getting a >>> little desperate (probably sound like it too). So any help would definitely >>> be appreciated. :) >>> >>> >>> On Fri, Nov 21, 2008 at 1:42 PM, Andrew Hughes wrote: >>> >>>> Hi, >>>> I'm trying to work out how I can add the following PojoNode to JXPath's >>>> context for evaluation. >>>> >>>> public class PojoNode extends java.util.ArrayList { >>>> public PojoNode(Pojo pojo) { >>>> this.pojo = pojo; >>>> } >>>> private Pojo pojo; >>>> public Pojo getPojo() { >>>> return pojo; >>>> } >>>> } >>>> >>>> >>>> >>>> The PojoNode tree above is (definitely) populated... then I setup and >>>> ask JXPath to evaluate an expression on it: >>>> >>>> >>>> JXPathIntrospector.registerDynamicClass(PojoNode.class,PojoDynamicPropertyHandler.class); >>>> JXPathContext jxPathContext = JXPathContext.newContext(rootPojoNode); >>>> PojoNode result = (PojoNode)jxPathContext.getValue("/"); //this always >>>> produces an empty result >>>> >>>> >>>> What concerns me is not the code I have written but the code I have not. >>>> I've got log statements in the PojoXInfoBean and PojoDynamicPropertyHandler >>>> (see below) but none every fire (in particular "I have been asked to >>>> look.." and "...w00t"). Consequently the PojoNode tree is not being >>>> traversed correctly and thus fails. I suspect that because PojoNode >>>> implements a Collection it's picked up buy another DynamicPropertyHandler. >>>> >>>> I feel like I have exhausted the javadocs and any help would be very >>>> very much appreciated. >>>> >>>> Thank You. >>>> >>>> >>>> ps if you wanted to see more code it is below.... >>>> >>>> public class PojoNodeDynamicPropertyHandler implements >>>> DynamicPropertyHandler { >>>> >>>> private final static Logger log = >>>> Logger.getLogger(PojoNodeDynamicPropertyHandler.class); >>>> >>>> public Object getProperty(Object PojoNode, String name) { >>>> log.debug("I have been asked to look for '"+name+"'"); >>>> Collection hits = new ArrayList(); >>>> for(PojoNode childPojoNode : (PojoNode) PojoNode){ >>>> if (childPojoNode.getPojo().getName().equals(name)){ >>>> hits.add(childPojoNode); >>>> } >>>> } >>>> >>>> log.debug("I have found '"+hits.size()+"' instances of '"+name+"'"); >>>> return hits; >>>> } >>>> >>>> public String[] getPropertyNames(Object PojoNode) { >>>> log.debug("JXPath has asked for this, w00t!"); >>>> HashSet nameSet = new HashSet(); >>>> nameSet.addAll(collectChildNames(PojoNode)); >>>> return (String[]) nameSet.toArray(new String[nameSet.size()]); >>>> } >>>> >>>> public void setProperty(Object arg0, String arg1, Object arg2) { >>>> throw new RuntimeException( >>>> "Manipulation through JXPath is not allowed.... (yet)"); >>>> } >>>> >>>> private HashSet collectChildNames(Object PojoNode) { >>>> HashSet nameSet = new HashSet(); >>>> for (PojoNode childPojo : (PojoNode) PojoNode) { >>>> nameSet.add(childPojo.getPojo().getName()); >>>> } >>>> return nameSet; >>>> } >>>> >>>> } >>>> >>>> ........................................................................................ >>>> >>>> public class PojoNodeXBeanInfo implements JXPathBeanInfo{ >>>> >>>> private static final Logger log = >>>> Logger.getLogger(PojoNodeXBeanInfo.class); >>>> >>>> >>>> public Class >>>> getDynamicPropertyHandlerClass() { >>>> >>>> log.debug("JXPath has asked for this, w00t!"); >>>> >>>> return PojoNodeDynamicPropertyHandler.class; >>>> >>>> } >>>> >>>> >>>> public PropertyDescriptor getPropertyDescriptor(String arg0) { >>>> >>>> log.debug("JXPath has asked for this, w00t!"); >>>> >>>> return null; >>>> >>>> } >>>> >>>> >>>> public PropertyDescriptor[] getPropertyDescriptors() { >>>> >>>> log.debug("JXPath has asked for this, w00t!"); >>>> >>>> return null; >>>> >>>> } >>>> >>>> >>>> public boolean isAtomic() { >>>> >>>> log.debug("JXPath has asked for this, w00t!"); >>>> >>>> return false; >>>> >>>> } >>>> >>>> >>>> public boolean isDynamic() { >>>> >>>> log.debug("JXPath has asked for this, w00t!"); >>>> >>>> return true; >>>> >>>> } >>>> >>>> } >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>> >> > ------=_Part_18194_33148752.1228083577635--