You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Andrew Hughes <ah...@gmail.com> on 2009/05/20 08:05:39 UTC

Re: [JXPath] Questions about pointers, listeners & filters

>From 10,000ft...

Perhaps I could register a PropertyChangeListener at each (JXPath) step is
taken? When a particular PropertyChangeEvent is fired by my contextBean
the PropertyChangeListener's at the 'current' step are fired, effectively
"resuming" or "re-evaluating" the JXPath eval. I guess I would need to know
what PropertyChangeEvents would need to occur at each pointer/contextBean in
order to match the test or xpath condition with the event.

Based on:
http://java.sun.com/javase/6/docs/api/java/beans/PropertyChangeListener.html
 and
http://java.sun.com/javase/6/docs/api/java/beans/PropertyChangeEvent.html



On Wed, Apr 29, 2009 at 3:39 PM, Andrew Hughes <ah...@gmail.com> wrote:

> Actually, this has all fallen apart. The filtering idea revolving around
> two context's (one private one public), each with it's own
> DynamicPropertyHandler for the Bean. The public would only expose the bean
> if MyBean.filtered==false. The second would expose MyBean without this
> restriction - but do so privately. A custom JXPath function used in this
> context could be used to toggle this filtered value... for example...
>
> public static boolean applyFilter(ExpressionContext context) {
>     ((MyBean)context.getValue()).setFiltered(true);
> }
>
> and this is applied to the context with the following expression...
>
>
> mynamespace:MyFunctionClass.applyFilter(/Path/To/Something[color="TRANSPARENT"]);
>
>
>
> The problem is that I can not define two seperate DynamicPropertyHandler's
> for the one class in seperate contexts :'(
>
> Any idea's?
>
> After loads of thought.. listeners are easy. Listeners can/should only be
> listening at the root pointer/context level (because they can listen to
> everything). My Bean itself is responsible for invoking the listener
> facility when something is constructed. The filter's above are invoked as
> they are applied as a listener.
>
> Hopefully there is a solution for the above,
>
> Cheers :)
>
>
> On Tue, Apr 28, 2009 at 6:06 AM, Adrian Mitev <adrian.mitev@googlemail.com
> > wrote:
>
>> Why don't you share us the solutions?
>>
>> On Mon, Apr 27, 2009 at 4:50 PM, Andrew Hughes <ah...@gmail.com>
>> wrote:
>> > I think I have a solution for both based on JXPath.
>> >
>> > Cheers && a HUGE thank's to JXPath && Matt.
>> >
>> >
>> > On Fri, Apr 24, 2009 at 12:09 PM, Andrew Hughes <ah...@gmail.com>
>> wrote:
>> >
>> >> Hi All - probably just Matt tho   :)
>> >> I've had some great results with JXPath, and I am now getting down to
>> the
>> >> nitty/gritty of what I am trying to achieve. Which is quite complex and
>> I've
>> >> no doubt that more experienced people than me exist in this area! Help
>> is
>> >> once again greatly appreciated!!!
>> >>
>> >> Background: I am dealing with dynamic objects (Nodes). Node's
>> >> appear/disappear at runtime and are encapsulated in a heirarchy of
>> HashMap's
>> >> for JXPath's context bean. This works fantastic, but I have two
>> remaining
>> >> mandatory requirements.
>> >>
>> >> Requirement 1: Listening
>> >> As a new node appears, listeners defined as expressions would like to
>> know
>> >> about this. For example, someone would like to know if a Ferrari ever
>> >> appears in the context bean:  //Car[@name="Ferrari"]
>> >> or /Transport/Vehicle/Car[@name="Ferrari"]. I believe that I should be
>> >> testing is if the newly created/removed node/pointer is found in any of
>> the
>> >> supplied listening expressions? Ideally this can be done by traversing
>> the
>> >> minimal number of object's as possible - and could be too inefficient
>> :'(
>> >> for use.
>> >>
>> >> Requirement 2: Filtering.
>> >> As a new node appear's I would like to know if I should include this
>> node
>> >> in the context bean hierarchy (i.e. addNewChild()) or ignore it. The
>> >> criteria is if the new node is found using an expression (include or
>> >> exclude). For example, if we don't deal with China then we might have
>> an
>> >> exclude expression /World/Asia/China or /World/Asia/*. Can I determine
>> if
>> >> the new node is within an includes/excludes expression without having
>> to add
>> >> the node to the context, then testing, then removing - becuase this has
>> the
>> >> potential to falsly invoke listeners in Requirement #1
>> >>
>> >> I'd like to know if there is any helpful functionality within jxpath
>> that I
>> >> am unaware of. I suspect there is
>> >>
>> >>
>> >> As usual... I'm incredibly thankful for any help I can get :)
>> >>
>> >>
>> >
>>
>>
>>
>> --
>> Although nobody can come back and make a new start, anyone can start
>> now and make a new end
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>