Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 77327 invoked from network); 11 Jan 2002 00:22:32 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 11 Jan 2002 00:22:32 -0000 Received: (qmail 26508 invoked by uid 97); 11 Jan 2002 00:22:37 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 26492 invoked by uid 97); 11 Jan 2002 00:22:37 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 26481 invoked from network); 11 Jan 2002 00:22:36 -0000 Date: Thu, 10 Jan 2002 16:22:28 -0800 (PST) From: "Craig R. McClanahan" To: Jakarta Commons Developers List Subject: Re: [DIGESTER] simple xml attribute to java attribute mapping? In-Reply-To: <458473676F1AC74A84EAB2F22004DA6DD8B7@mail.nextance.com> Message-ID: <20020110162016.L51768-100000@icarus.apache.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: localhost 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Thu, 10 Jan 2002, Scott Sanders wrote: > Date: Thu, 10 Jan 2002 16:00:52 -0800 > From: Scott Sanders > Reply-To: Jakarta Commons Developers List > To: commons-dev@jakarta.apache.org > Subject: [DIGESTER] simple xml attribute to java attribute mapping? > > What is the best way in digester to do a simple xml attr -> java attr > mapping. > > For example: > > > > And the class looks like: > > Class Tag { > public void setName(String name) {...} > public void setStyleName(String style) {...} > } > > The SetPropertiesRule handles the name->setName() case, but what is the > easiest way to handle the style->setStyleName() case? > > Silly question, but my brain is dead, I am currently using > CallMethodRule with CallParamRule, and I think there should be a better > way :) > There aren't any current Digester rules that do that kind of thing for you. Presumably, you'd want to be able to map more than one attribute-property pair. A way to make this work would be to define a BeanInfo class for your bean class that returned a PropertyDescriptor for the 'style' property that says the setter method is really 'setStyleName'. This will get picked up by the introspection mechanism in PropertyUtils (which is what Digester is using underneath), with no changes to Digester. > Scott > Craig -- To unsubscribe, e-mail: For additional commands, e-mail: