Vincent Massol wrote:
Hi,
I am using the org.apache.avalon.framework.configuration.Configuration object in some of my Configurable components and I find that it is not very easy to decide whether a Configuration contains an attribute or not. There is a getAtribute() which takes a default value but that's not enough.
I'm proposing to add a Boolean containsAttribute(String name). What do you think ? Should I go ahead a send a patch (in other words, do you agree to include it in the base Avalon framework) ?
Can you provide a use case for such a thing? How do you propose to use the containsAttribute() method? Why *exactly* is the defaulted version of getAttribute() not enough?
I need some more info if I am going to back you on this.
Or is there another that I have missed of doing this ? With the current code base I can see 2 ways of doing this : 1/ testing for a ConfigurationException, which does not seem a good idea 2/ call getAttributeNames() and iterate to find if the attribute exist, which is also not that fine.
Why do you need to know if it does not exist?
Also have you considered this:
String value = configuration.getAttribute( "name", null ); if ( null == value ) { // do the processing if it is not here }
--
"They that give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." - Benjamin Franklin
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>