[jdom-interest] getChildTextNormalize()

Kent C. Johnson kentyman23 at hotmail.com
Mon Oct 1 15:25:49 PDT 2001


Note that I'm CC'ing this to jdom-interest instead of jdom-commits, since I 
should have posted my original to jdom-interest instead (and have since 
reposted to jdom-interest).

Alex,

I agree with you.  I originally got started with the normalize stuff because 
I was learning JDOM in a class at work, and part of the exercise was to 
normalize the text retrieved from a child instead of just trimming it.  I of 
course, put "getChildTextNormalize" instead of "getChildTextTrim", and found 
that it did not exist.  No one in the class could believe it, but the docs 
confirmed that it wasn't there.  I liked what I had seen of JDOM so far, and 
like it being declared incomplete by newbies like my fellow co-workers in 
the class, so I decided to try to change it.

Since bringing up whether getChildTextNormalize() should be added, I have 
resparked a debate on whether or not these getChildText*() methods should 
exist at all.  My only point is this: if you have getChildTextTrim(), and 
you have a getTextTrim() and getTextNormalize(), you must for completeness 
have a getChildTextNormalize().  I realize that getTextNormalize() was added 
after the getChildText*() methods, but that doesn't mean it's child version 
shouldn't be added as well.

I believe that for now, getChildTextNormalize() should be added to Element.  
If everyone agrees that there is now too much get*Text*() clutter in 
Element, I suggest these ideas involving a helper class:

1) Delete all get*Text*() methods from Element except getText() and get 
getChildText().

2) In a helper class (I'll call it JDOMHelper) have static methods 
trimText(String) and normalizeText(String).  Note that trimText(String) will 
be the same as String.trim(), but should be left in case someone wanted to 
(for some unforseeable reason) extend this method.

I am not saying the above is necessarily worth it, or the Right Thing(tm) to 
do, but I do think it needs to be done if adding getChildTextNormalize() 
does not go over well with the rest of y'all.

Do you guyes agree?

Regards,
Kent


>From: "Jose Alejandro Cardenas" <jcardena at wctravel.com>
>To: <jdom-commits at dorothy.denveronline.net>
>Subject: [jdom-commits] getChildTextNormalize()
>Date: Mon, 1 Oct 2001 10:23:05 -0400
>
>Kent,
>
>This is also my first message to this list but I have been using JDOM for
>almost a year.  I do not think taking out the methods to access the text
>from a child is a good idea.  However having a helper class to help
>normalize the contents seems reasonable to me.  I am also not sure how
>things are added to this open source project, but in webmacro or others I 
>am
>involved it is based on votes and community consideration.
>
>Alex
>
>
>----- Original Message -----
>From: <jdom-commits-admin at dorothy.denveronline.net>
>To: <jdom-commits at dorothy.denveronline.net>
>Sent: Sunday, September 30, 2001 2:08 AM
>Subject: jdom-commits digest, Vol 1 #208 - 1 msg
>
>
> > Send jdom-commits mailing list submissions to
> > jdom-commits at lists.denveronline.net
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > http://lists.denveronline.net/mailman/listinfo/jdom-commits
> > or, via email, send a message with subject or body 'help' to
> > jdom-commits-request at lists.denveronline.net
> >
> > You can reach the person managing the list at
> > jdom-commits-admin at lists.denveronline.net
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of jdom-commits digest..."
> >
> >
> > Today's Topics:
> >
> >    1. getChildTextNormalize() (Kent C. Johnson)
> >
> > --__--__--
> >
> > Message: 1
> > From: "Kent C. Johnson" <kentyman23 at hotmail.com>
> > To: jdom-commits at jdom.org
> > Date: Sat, 29 Sep 2001 21:43:37 -0500
> > Subject: [jdom-commits] getChildTextNormalize()
> >
> > This is a multi-part message in MIME format.
> >
> > ------=_NextPart_000_5cf6_5d5f_6df4
> > Content-Type: text/plain; format=flowed
> >
> > earlier on jdom-interest i was talking about adding the
> > getChildTextNormalize() methods to Element.java, since getChildText() 
>and
> > getChildTextTrim() exist.  i'm am completely new to the project, and in
>fact
> > new to any open source project, so i'm not sure how things get decided
> > around here (vote on things / just gets decided Jason and Brett /
>whatever).
> >   anyway, i think that either getChildTextNormalize() needs to be added 
>to
> > Element.java, or that method and all the other getChildText*() methods
>need
> > to be moved to a helper class.  i have a patch which adds the
> > getChildTextNormalize() methods to Element.java
> > (Element+getChildTextNormalize.patch).  i also have a patch which takes
>all
> > of those methods out of Element.java 
>(Element-getChildText_deleted.patch),
> > along with a working version of a helper class (JDOMHelper.java).  i 
>will
> > attach these 3 files.
> > since this is my first submission i hope someone is able to check my 
>work,
> > though i have already tested by hand.  also, i didn't know how it worked
> > adding the @author to the javadocs, so i added my name in 
>JDOMHelper.java
> > and Element+getChildTextNormalize.patch.  in the latter of the two, 
>since
>i
> > basically just copied and modified code, perhaps my name should be taken
>out
> > of the javadocs (but if not, that would be cool :) ).  i didn't put my
>name
> > in for the Element-getChildText_deleted.patch, since it just deletes 
>code.
> > :)
> > if you have any questions regarding these changes please ask me.  also
>note
> > that some might argue that all the getText*() methods should be part of
>the
> > JDOMHelper, but i disagreed, so i didn't do it yet.  if y'all think they
>all
> > need to move, i can do that too.
> > oh, i was just thinking, maybe we would just deprecate the 
>getChildText*()
> > methods in Element.java, so it doesn't break old code.  if so,
> > Element-getChildText_deleted.patch won't be useful.  i will also include 
>a
> > patch Element-getChildText_deprecated.patch which will just mark those
> > methods as deprecated.
> > one more thing, please check to make sure i did the javadocs right.  i'm
> > pretty sure i did, but i had never played with it before today.
> >
> > quick recap of files:
> > Element+getChildTextNormalize.patch - patch adds getChildTextNormalize()
> > methods
> > Element-getChildText_deleted.patch - patch deleted all getChildText*()
> > methods
> > Element-getChildText_deprecated.patch - patch deprecated all
>getChildText*()
> > methods
> > JDOMHelper.java - helper class with static versions of all 
>getChildText*()
> > methods including getChildTextNormalize()
> >
> > thanks for considering my work,
> > kent
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at 
>http://explorer.msn.com/intl.asp

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




More information about the jdom-interest mailing list