Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 15762 invoked from network); 10 Feb 2004 13:56:55 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 10 Feb 2004 13:56:55 -0000 Received: (qmail 79490 invoked by uid 500); 10 Feb 2004 13:56:24 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 79406 invoked by uid 500); 10 Feb 2004 13:56:23 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 79329 invoked from network); 10 Feb 2004 13:56:22 -0000 Received: from unknown (HELO mail04.agrinet.ch) (81.221.250.53) by daedalus.apache.org with SMTP; 10 Feb 2004 13:56:22 -0000 Received: from active.ch (217.192.238.66) by mail04.agrinet.ch (7.0.024) (authenticated as c.hauser) id 40224C8A000AF55C for commons-user@jakarta.apache.org; Tue, 10 Feb 2004 14:56:17 +0100 Message-ID: <4028E2DE.7020709@active.ch> Date: Tue, 10 Feb 2004 14:55:42 +0100 From: Christian Hauser User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 X-Accept-Language: en-us, en MIME-Version: 1.0 To: commons-user@jakarta.apache.org Subject: [Digester] HashMap on top of stack Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi list I'd like to use Digester to parse an XML file. The root element ('definitions') should correspond to a HashMap. This HashMap should contain key/value pairs, whereas the value is a bean of type DefinitionBean and the key is stored within the DefinitionKey. Here what I have so far: Digester d = new Digester(); d.addObjectCreate("definitions", HashMap.class); d.addObjectCreate("definitions/definition", DefinitionBean.class); d.addBeanPropertySetter("definitions/definition/key", "key"); d.addObjectCreate("definitions/definition/properties/property", DefinitionProperty.class); d.addBeanPropertySetter("definitions/definition/properties/property/xyz", "xyz"); d.addSetNext("definitions/definition/properties/property", "addProperty"); // And this stuff here isn't working of course, // but shows maybe what I'd like to do. DefinitionBean bean = (DefinitionBean) d.pop(); HashMap hashMap = (HashMap) d.pop(); hashMap.put(bean.getKey(), bean); d.push(hashMap); d.push(bean); HashMap map = (HashMap) d.parse(getTestXmlReader()); When the definitions/definition tag ends I'd like to do something like hashMap.put(bean.getKey(), bean) whereas bean is of type DefinitionBean. The DefinitionBean is on top of the stack and below the HashMap. Then of course the DefinitionBean should be removed from stack for the next to come. I don't see a way to do that and would be very happy for every hint on that. Christian --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org