On Sat, 10 Nov 2001 21:22, Jeff Turner wrote: > Hi, > > The javadocs for Configuration state: > > "The contract surrounding the Configuration is that once it is > created, information never changes." > > There are two variants of getChild: > > Configuration getChild(java.lang.String child) > Configuration getChild(java.lang.String child, boolean createNew); > > Now I'm wondering, what's the "createNew" attribute for? Why would you > want to create a new Configuration, when you can't do anything with it > (it's read-only). > > Even more surprising is that for the single arg version, "createNew" is > true. So getChild("foo") won't return null even if no child "foo" > exists. I suppose this prevents inadvertent NPEs, but also prevents > useful tests like: > > if (conf.getChild("foo") != null) { > // .. > } > > Is there a reason for returning an empty child Configuration, or is this > a bug?
Its a feature so that we can support a pattern like c = getChild("foo").getChild("bar").getChild("baz"); rather than Configuration foo = getChild("foo"); if( null != foo ) { Configuration bar = getChild("bar"); if( null != bar ) { c = getChild("baz"); } } -- Cheers, Pete ---------------------------------------- Whatever you do will be insignificant, but it is very important that you do it. --Gandhi ---------------------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>