commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Price <>
Subject [digester] setting a default value for a callMethod
Date Mon, 17 Mar 2003 20:54:20 GMT
The answer to this question seems like it should be trivial.  But I am 
just not seeing it.  If someone could help that'd be great.

My digester has hit upon a pattern, which triggers a method in the top 
object on the call stack.  Fine, that's normal.  However, the method 
expects an integer argument and in my XML file the element representing 
this pattern is empty.  This is throwing a SAXException, as expected.

There are several solutions:

1. Overload my method with a no-arg version.  This doesn't seem like a 
good idea, changing my class structure simply to satisfy the digester, 
because a no-arg version would do nothing.

2. Not include the element at all if it does not contain a value, so 
that the digester doesn't see the pattern.  This doesn't seem like a 
great solution either.

3. Use a dummy value (-1 in my case) and then have the method check for 
the dummy value.  This still seems a little inelegant.

Hmm... I'm wondering if there's a way to tell the digester that I don't 
want to call that method if the element at the matching pattern is 
empty?  Or is this getting too detailed, in which case I'd have to look 
into JDOM or something.



View raw message