commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Baltz, Kenneth" <>
Subject [Digester]How do you populate a map?
Date Mon, 10 Feb 2003 23:04:48 GMT
I'm really embarrassed after posting a HowTo on populating a map, but I've
found that it's not as clear as I thought it was.  I know how to do it with
the following example:

<?xml version='1.0'?>
  <key name='The key'/>
  <value name='The value'/>

But how to do it with this?

<?xml version='1.0'?>
  <key name='KeyA'/>
  <value name='ValueA'/>  
  <key name='KeyB'/>
  <value name='ValueB'/>

CallMethodRule is only invoked at the end of <map>, so you can't call it
twice, once for each key, value pair.  
The situation I have that I actually need to solve looks more like this:

	<Book title="The Firm" />	
	<Book title="The Cat in the Hat" />

I would want Library to be a HashMap with titles for keys and Book objects
for values.  You can't use a CallMethodRule on Book because the put() method
belongs to Library, not Book.


BTW, I realize you can do this by creating proxy objects that call put() for
you.  That's inelegant IMHO and I was hoping that Digester 1.4 had solved
this issue.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message