Re: [digester] Grabbing data from sub-element attributes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 All, Wouldn't you know it, just after I posted, I had an epiphany: On 5/13/2011 5:33 PM, Christopher Schultz wrote: entities entity foosome value/foo barsome other value/bar baz id=123 / /entity /entities The solution is: digester.addObjectCreate(entities/entity, Entity.class); digester.addSetNestedProperties(entities/entity, { foo, bar, baz }, { foo, bar, null }); // ignore baz // go back and get baz digester.addSetProperties(entities/entity/baz, id, baz); Sorry for the noise. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3Npo0ACgkQ9CaO5/Lv0PDG0ACgpYqGZOM054nO/bLNypyfrKPx iysAnjqdjkrsQT4l3qlj1OLJp4vG4sbT =n7/z -END PGP SIGNATURE- - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] Grabbing data from sub-element attributes
On Fri, May 13, 2011 at 5:45 PM, Christopher Schultz ch...@christopherschultz.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 All, Wouldn't you know it, just after I posted, I had an epiphany: On 5/13/2011 5:33 PM, Christopher Schultz wrote: entities entity foosome value/foo barsome other value/bar baz id=123 / /entity /entities The solution is: digester.addObjectCreate(entities/entity, Entity.class); digester.addSetNestedProperties(entities/entity, { foo, bar, baz }, { foo, bar, null }); // ignore baz // go back and get baz digester.addSetProperties(entities/entity/baz, id, baz); snip/ Yeah, and probably more than one way even with out of the box rules: d.addObjectCreate(entities/entity, Entity.class); d.addCallMethod(entities/entity/foo, setFoo, 0); d.addCallMethod(entities/entity/bar, setBar, 0); d.addCallMethod(entities/entity/baz, setBaz, 1); d.addCallParam(entities/entity/baz, 0, id); -Rahul Sorry for the noise. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3Npo0ACgkQ9CaO5/Lv0PDG0ACgpYqGZOM054nO/bLNypyfrKPx iysAnjqdjkrsQT4l3qlj1OLJp4vG4sbT =n7/z -END PGP SIGNATURE- - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] Grabbing data from sub-element attributes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Rahul, On 5/13/2011 5:53 PM, Rahul Akolkar wrote: Yeah, and probably more than one way even with out of the box rules: d.addObjectCreate(entities/entity, Entity.class); d.addCallMethod(entities/entity/foo, setFoo, 0); d.addCallMethod(entities/entity/bar, setBar, 0); d.addCallMethod(entities/entity/baz, setBaz, 1); d.addCallParam(entities/entity/baz, 0, id); Thanks for the tip... that might actually be somewhat simpler code than I have now. I'm using setNestedProperties and enumerating them because I need to re-name some of the properties. But, that requires that I enumerate all of them, even those I want to ignore, otherwise I'll get an error. If I use addCallMethod, the Digester will probably ignore anything for which there is no rule. Thanks, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3NrH4ACgkQ9CaO5/Lv0PASVwCfSEYMFGwDYuOj0fZvaFuDl+YD 9tkAoIOnGQk4ERImSnU7LVW501rYjYEF =7vJb -END PGP SIGNATURE- - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] Grabbing data from sub-element attributes
Hi Christopher, I suggest you following Rahul's suggestion, SetNestedPropertiesRule is not efficient as a direct invocation. Moreover, for foo/bar properties, there's a 3rd way to set them: d.addObjectCreate(entities/entity, Entity.class); d.addBeanPropertySetter(entities/entity/foo); d.addBeanPropertySetter(entities/entity/bar); d.addCallMethod(entities/entity/baz, setBaz, 1); d.addCallParam(entities/entity/baz, 0, id); HTH, Simo http://people.apache.org/~simonetripodi/ http://www.99soft.org/ On Sat, May 14, 2011 at 12:11 AM, Christopher Schultz ch...@christopherschultz.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Rahul, On 5/13/2011 5:53 PM, Rahul Akolkar wrote: Yeah, and probably more than one way even with out of the box rules: d.addObjectCreate(entities/entity, Entity.class); d.addCallMethod(entities/entity/foo, setFoo, 0); d.addCallMethod(entities/entity/bar, setBar, 0); d.addCallMethod(entities/entity/baz, setBaz, 1); d.addCallParam(entities/entity/baz, 0, id); Thanks for the tip... that might actually be somewhat simpler code than I have now. I'm using setNestedProperties and enumerating them because I need to re-name some of the properties. But, that requires that I enumerate all of them, even those I want to ignore, otherwise I'll get an error. If I use addCallMethod, the Digester will probably ignore anything for which there is no rule. Thanks, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3NrH4ACgkQ9CaO5/Lv0PASVwCfSEYMFGwDYuOj0fZvaFuDl+YD 9tkAoIOnGQk4ERImSnU7LVW501rYjYEF =7vJb -END PGP SIGNATURE- - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org