[jdom-interest] no getChildTextNormalize() ?
Alex Rosen
arosen at silverstream.com
Mon Oct 1 08:08:59 PDT 2001
> I was hoping you would join this thread. Didn't you already
> start a helper class for this kind of thing?
Yeah. As usual, I got frustrated by trying to do too much. I wanted to have
addContent() and removeContent() helpers that would preserve the document's
indentation. These were way harder than the other helpers, so I gave up
after a while, but I should just go ahead and check in what I've got to
jdom-contrib. I'll try to do this soon. Here's the current plan:
public class TextHelper
{
public static String getChildText(Element parent, String name)
public static String getChildText(Element parent, String name, Namespace
ns)
public static String normalize(String text)
[plus various combinations of getText/getChildText/trim/normalize]
}
public class RequiredHelper
{
public static String getText(Element element)
throws MissingDataException
public static String getChildText(Element parent, String name)
throws MissingDataException
public static String getChildText(
Element parent, String name, Namespace ns)
throws MissingDataException
public static String getAttributeValue(Element element, String name)
throws MissingDataException
public static String getAttributeValue(
Element element, String name, Namespace ns)
throws MissingDataException
}
The RequiredHelper came up back when we changed getChild() etc. to return
null instead of throw a MissingDataException. But nobody seems to complain
anymore, I wonder if it's still needed. It now seems kind of silly to me. If
it's still needed, do we also need RequiredHelper.getChildTextNormalize()
and all its friends? This quickly spirals out of control. That's why I
punted a while ago on data conversion helpers
(http://lists.denveronline.net/lists/jdom-interest/2001-April/005965.html).
Any comments are welcome.
Alex
More information about the jdom-interest
mailing list