[jdom-interest] Re: getAttribute("prefix:name")

philip.nelson at omniresources.com philip.nelson at omniresources.com
Tue Mar 27 09:58:00 PST 2001


> Read it one more time. ;-)  I'm looking for 
> getAttribute(String, String)
> not a constructor Attribute(String, String).  I don't see a 
> getAttribute(String,
> String), so there shouldn't be a conflict.
> 

You are correct!  I guess my five second answers aren't always the best
thing.  Yes it could be done.  The only other reason I for not doing it is
that there are a number of other methods that have similar signatures
getAttribute(name)
getAttribute(name, namespace)
getChild(name)
getChild(name, namespace)
getCopy(name)
getCopy(name, namespace)
and more...

I really don't have deep feelings about this but in an api I use frequently,
this sort of consistency is one more reason I don't have to go to the
javadocs.  I can deduce the parameters without having to look at the docs.
That is a subtle and useful feature of an api.

> Not sure if getAttribute() is that high of a performance 
> concern, either.
>  Could it be you were thinking of the constructor when you mentioned
> that?  I don't see it normally being used in any tight loops. 

Actually, I *was* thinking of getAttribute as a performance problem, a
little anyway.  Running a profiler on some of my own code, I saw that second
to building the document from a file, getAttribute with it's heavy use of
String.equals() was where most of my time was spent.  There are reasons for
this, one of which is a somewhat large number of attributes in this
application and two because of the way getAttribute looks for matches.



More information about the jdom-interest mailing list