commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hippo Man <hippo.mail...@gmail.com>
Subject Fwd: [jxpath] Passing casting information within a path-based setter?
Date Sat, 30 Jul 2011 01:20:25 GMT
I'm sorry.  I have to figure out how to make my email client
auto-respond to this mailing list.

Here's my recent response, which accidentally was sent to the
sender and not this list ...

On Fri, Jul 29, 2011 at 20:14, Martin Gainty <mgainty@hotmail.com> wrote:
>
> [ ... ]
>
> MG>Create the properly casted item BEFORE passing into createPathAndSetValue
> method
> MG>TheChild child=(TheChild)dataArray[i].varString;

Thank you very much, but unfortunately, I am unable to do this
in the application that I'm working on. We have several
hundred beans which get auto-generated from some changing
configuration information, and the _only_ way we can set
values within our application is to do so via the xpath-based
setters. Sadly, we can't instantiate objects before calling
createPathAndSetValue.

Is there perhaps some "neutral", do-nothing syntax that can
be embedded in the xpath setter? Perhaps some sort of
comment?

For example, if there were comments that were delimited by
"{{" and "}}" (I know there aren't), the xpath setter could look
something like this:

"/{{cast:TheChild}}dataArray[1]/varString"

Then, I could parse this casting information out of the "name"
parameter for createObject, and I could then do the casting
myself, within that method.

If out-of-the-box jxpath doesn't allow comments within the
xpath setter, is it possible, perhaps, to write a custom parser?

Um ... I guess I should rephrase that: is it relatively simple
to write a custom parser?


> MG>There is a way to divine the type of Object passed in with
> Class.instanceOf  ..something like this should test the Type of class
> [ ... etc. ... ]

But wouldn't this only work if I previously set the object
to TheChild, as you suggested above?

If it turns out that I can't easily do what I want, I'll try to figure
out some sort of workaround within our application. But I'd
prefer to get this to work solely via xpath setters and the
createObject method, if at all possible.

Am I out of luck?

Thanks again for your help!

--
 hippo.mailbox@gmail.com

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


Mime
View raw message