[jdom-interest] Another suggestion for the Element class

Michael Skells mskells at aspirebanking.com
Wed Nov 15 07:24:44 PST 2000


I agrre that the API should not be cluttered.

Surely it should not be a subclass but an adaptor.
That would allow for the use of format conversions 
[ addTextHex(int i) addTextDate(DateFormatter df, int i) ]
to be added until people get bored ....


Mike

> -----Original Message-----
> From: Elliotte Rusty Harold [mailto:elharo at metalab.unc.edu]
> Sent: 15 November 2000 14:14
> To: jdom-interest at jdom.org
> Subject: Re: [jdom-interest] Another suggestion for the Element class
> 
> 
> At 2:02 AM -0800 11/14/00, Jason Hunter wrote:
> >>  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 would prefer not to clutter the API with these extra methods. 
> Smaller APIs are more beautiful, IMHO. As you point out, doing 
> without them is trivial. If you really find you need them, then it's 
> straight-forward to write a subclass of Element that provides them 
> that you can use in your own code and the rest of us can be 
> blissfully ignorant of.
> -- 
> 
> +-----------------------+------------------------+-------------------+
> | Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
> +-----------------------+------------------------+-------------------+
> |                  The XML Bible (IDG Books, 1999)                   |
> |              http://metalab.unc.edu/xml/books/bible/               |
> |   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
> +----------------------------------+---------------------------------+
> |  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
> |  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
> +----------------------------------+---------------------------------+
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com



More information about the jdom-interest mailing list