[jdom-interest] Another suggestion for the Element class

Jason Hunter jhunter at acm.org
Tue Nov 14 02:02:14 PST 2000

> Having to use String.valueOf repeatedly can be tedious (although it is
> certainly workable).  My recommendation would be to add some
> convenience
> methods to handle conversion of primitive types into Strings:
>     public Element setText(int iTextValue);
>     public Element setText(long lTextValue);
>     ...
> The method bodies would follow this format:
>     public Element setText(int iTextValue) {
>         return setText(String.valueOf(iTextValue));
>     }
> This would allow quick conversion of primitive types without requiring
> the programmer to do the String conversions manually every time.
> Comments?

I normally like convenience, but here I'd like to follow the style of
setText() in classes like Label, TextComponent, TextField, etc where the
method takes only a String and lets the caller handle conversions.


More information about the jdom-interest mailing list