commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vos, Jerry R." <j...@anl.gov>
Subject RE: JXPath and custom collection
Date Mon, 24 Jul 2006 22:11:56 GMT
Thanks Paul, your interpretation was correct. I did see Container
before, and while I don't think is going to work in this case, it did
make me think of using the DynamicPropertyHandler to do this.  I was
actually considering using the DynamicPropertyHandler for something
else, but didn't think of using it for this purpose.

Basically, what I'm going to try and do is just have my
DynamicPropertyHandler return the normal properties for my class. So in
my example I'd do something like:

public class BarHandler implements DynamicPropertyHandler {
public Object getProperty(Object object, String propertyName) {
	if (propertyName.equals("x")) {
		return ((Bar) object).getSubContexts();
	}
	return null;
}
		
public String[] getPropertyNames(Object object) {
	return new String[] { "x" };
}
		
public void setProperty(Object object, String propertyName, Object
value) {
	throw new UnsupportedOperationException("");
}
}

And then something like
JXPathIntrospector.registerDynamicClass(Bar.class, BarHandler.class);

Anyway, will update with the results of this.  If anyone sees an obvious
problem with that please let me know.

Jerry

> -----Original Message-----
> From: Paul Copeland [mailto:tech@jotobjects.com]
> Sent: Monday, July 24, 2006 4:52 PM
> To: Jakarta Commons Users List
> Subject: Re: JXPath and custom collection
> 
> Essentially you are asking if you can access non-child attributes of a
> Collection. Normally you would access the elements of a Collection as
> nodes with iterate (rather than getValue).  It seems to want to treat
> Collections as NodeSets rather than as Nodes. So it works if Bar has
an
> ArrayList property, but not if Bar is a subclass of ArrayList as in
your
> example.  Maybe you can do something with a Container...
> 
>
http://jakarta.apache.org/commons/jxpath/apidocs/org/apache/commons/jxpa
th
> /Container.html
> 
> 
> Vos, Jerry R. wrote:
> 
> >public class Bar extends ArrayList {
> >            public String getX() { return "xValue" }
> >}


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message