[jdom-interest] Helper methods [eg]
Scott Smith
ssmith at summitlogic.com
Thu Apr 19 08:29:19 PDT 2001
I just have a comment of the findChild() method:
This seems to be handled well now with the Werken XPath implementation. For
example:
*[@name] matches any element that has a name attribute
*[@name='Scott'] matches any element that has a name attribute whose value
is 'Scott'
> -----Original Message-----
> From: Rosen, Alex [mailto:arosen at silverstream.com]
> Sent: Wednesday, April 18, 2001 9:28 PM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] Helper methods [eg]
>
>
> I would like to bring up the topic of adding helper methods
> to JDOM, so
> mulitiple users don't have to write common routines
> themselves. I envision
> these as static methods on one or more classes in a packaged named
> org.jdom.helpers or org.jdom.util. Some possible examples include:
>
> - Getters which would throw exceptions if the requested data
> is not available:
> getRequiredAttribute(), getRequiredChild()...
>
> - Getters and setters for datatypes, e.g. getIntAttributeValue(),
> setIntAttributeValue(), getIntText(), setIntText(),
> getIntChildText()...
>
> - Modification methods which preserve formatting - an
> addChild() method which
> would add necessary indentation so the XML continued to look nice, and
> removeChild() which removed the remaining whitespace so there
> wasn't a big
> empty hole in the document.
>
> - findChild(), which could find the child element with a
> specific attribute
> value, for example.
>
> Before getting bogged down on which methods to offer, the
> first question is: do
> we want these helpers, and if so, should we try to provide a
> lot of helpers
> that might be useful to some people, or only a few that will
> be the most useful
> to the widest audience?
>
> These helpers would make JDOM easier to use for all
> programmers. It would
> prevent the same methods from having to be implemented over
> and over again by
> different developers, each implementation which might have
> its own bugs. It
> helps us keep the core API (Element, Document, etc.) to the
> minimum necessary,
> by allowing us to add frequently-requested but non-essential
> methods somewhere
> else. (For example, I think it would be great to move the
> getChildText() and
> text-trimming methods here.)
>
> Disadvantages: Hard to know when to stop adding helpers. There may be
> significant differences of opinions on the desired behavior
> of some of the
> methods. More API for users to learn (although not core API).
>
> Any opinions?
>
> Alex Rosen
> SilverStream Software
> _______________________________________________
> 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