Return-Path: Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 28402 invoked by uid 98); 18 Dec 2002 22:19:44 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Received: (qmail 28382 invoked from network); 18 Dec 2002 22:19:42 -0000 Received: from daedalus.apache.org (HELO apache.org) (63.251.56.142) by nagoya.betaversion.org with SMTP; 18 Dec 2002 22:19:42 -0000 Received: (qmail 51022 invoked by uid 500); 18 Dec 2002 22:18:18 -0000 Received: (qmail 50992 invoked from network); 18 Dec 2002 22:18:18 -0000 Received: from www.shareowner.com (HELO shareowner.com) (66.46.24.147) by daedalus.apache.org with SMTP; 18 Dec 2002 22:18:18 -0000 Received: from exchange.int.shareowner.com (gw.shareowner.com [66.46.24.163]) by shareowner.com (8.11.6/8.11.6) with ESMTP id gBIM81905358 for ; Wed, 18 Dec 2002 17:08:01 -0500 Received: by exchange.int.shareowner.com with Internet Mail Service (5.5.2653.19) id <4Q6NZ0Q5>; Wed, 18 Dec 2002 17:18:18 -0500 Message-ID: From: pqin@shareowner.com To: commons-user@jakarta.apache.org Subject: RE: [Digester]How to populate a HashMap? Date: Wed, 18 Dec 2002 17:18:14 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C2A6E3.5B729C60" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------_=_NextPart_001_01C2A6E3.5B729C60 Content-Type: text/plain public class MyMap() { private Map _mymap ; public MyMap() { _mymap = new HashMap() ; } public void addBook(Book mybook) { _mymap.put(mybook.getTitle(), mybook) ; } } public class MyDigester() { public void load() throws IOException, SAXException { Digester d = new Digester() d.addObjectCreate("library", "MyMap") ; d.addObjectCreate("library/book", "Book") ; d.addBeanPropertySetter("library/book/title", "setTitle") ; d.addBeanPropertySetter("library/book/author", "setAuthor") ; d.addSetNext("library/book", "addBook") ; File input = new File("myxmlfile") ; MyMap m = (MyMap) d.parse(input) ; } } Regards, Phillip Qin "This Guy Thinks He Knows Everything" Canadian Shareowner 121 Richmond Street W, 7th Floor Toronto, ON M5H 2K1 (416) 595-9600 ext 291 -----Original Message----- From: Baltz, Kenneth [mailto:Kbaltz@firstam.com] Sent: December 18, 2002 5:06 PM To: Jakarta Commons Users List Subject: [Digester]How to populate a HashMap? How would I go about doing the following using Digester? Given XML as such: TITLE TEXT AUTHOR TEXT ... Assume there's a Book bean with title and author properties. How can I make the digester read in the books and put them in a HashMap by title? I can't see how to pass the object on the top of the stack as an argument to a method call. K.C. Baltz ------_=_NextPart_001_01C2A6E3.5B729C60--