[jdom-interest] Setting value of an attribute resets its type
Victor Toni
victor.toni at ebuconnect.de
Wed Apr 26 05:44:54 PDT 2006
Edelson, Justin wrote:
> Victor Toni wrote:
>> Having noticed that setting the value of an attribute via the
>> convenience methods in the Element class ("setAttribute(String name,
>> String value)" and "setAttribute(String name, String value, Namespace
>> ns)") will reset its type I wonder if this is on purpose.
>> Maybe this functionality is not widely used and it went unnoticed?
>>
> Here's a patch against the current HEAD that adds two new
> setAttribute() methods, both with a type parameter. There's probably
> a more clever way to add code into AttributeList so that you don't
> have to always pass in the correct type, but that seemed it could
> have unintended consequences.
>
There are already unintended consequences namely that the type is reseted if the value of the attribute is changed (meaning set anew, even with the old value).
This is not what you'd want if you change the value of an ID.
My concern was more of correctness of the current implementation than having new convenience methods (which actually aren't convenient because one would have to first query the type of the attribute to change it's value).
Another point I dislike at the current implementation is the creation of a new object on each change.
IMHO convenience methods should have a real benefit and one should rather try to reduce them than to increase them in number.
More information about the jdom-interest
mailing list