Re: Still to do - Text 'merger'

Grzegorz <[email protected]> Wed, 4 Apr 2012 17:48:31 +0200
Newsgroups gmane.comp.java.jdom.general
Message-ID <CA+DoOicRxXoH_mcJid1Zy9DXB8HHAB4UZ4GbE7ER5FPF50vZsA@mail.gmail.com>
Hello,

Sorry for late response...

Why not simply mergeConsecutiveTextNodes? It would just say what it does.

I would also prefer to have recursive version as well - yes, it is a
three-liner yet it takes some time and attention to read and understand
what this three-liner does. Adding a boolean parameter does not seem an
overhead.

I would also think of some automation... but this would be a performance
penalty.

Regards,
GK

2012/4/4 Oliver Ruebenacker <[email protected]>

>     Hello Rolf, All,
>
>  I think most users would be puzzled what it means to "simplify"
> text. It sounds as if the text itself is affected, rather than its
> representation. I would call it Element.defragmentText(). Many people
> know that if you defragment a file, the content stays the same.
>
>     Take care
>     Oliver
>
> On Wed, Apr 4, 2012 at 12:05 AM, Rolf Lear <[email protected]> wrote:
> > Hi all.
> >
> > I have moved this code in as the new method Element.simplifyText().
> >
> >
> https://github.com/hunterhacker/jdom/commit/d4b5c67f1df51cacf05e704e238f1d5361828233#diff-0
> >
> > It is a non-recursive method. I think the name is better than 'merge',
> > 'join', or 'normalize'.
> >
> > I think the recursive means of doing it is easy enough to code
> > (three-liner), so it does not add much value.
> >
> > I think it has enough value to be included.
> >
> > Unless someone can come up with better names, options, I think it will
> stay.
> >
> > Rolf
> >
> >
> > On 03/04/2012 9:49 AM, Rolf Lear wrote:
> >>
> >>
> >> Hi all.
> >>
> >> I have been playing with a problem related to multiple-adjacent-text
> >> content in Elements. For example:
> >>
> >> Element root = new Element("Root");
> >> root.addContent(new Text("Hello"));
> >> root.addContent(new Text(" "));
> >> root.addContent(new Text("World!"));
> >>
> >> I think there is a useful concept of 'merging' consecutive Text items in
> >> to one. The code is simple enough, and I have written it, and it works.
> >> This is similar to the 'normalize' function of DOM's Node.
> >>
> >> The questions are:
> >> 1. Should the code be part of the JDOM API? Is it useful?
> >> 2. The way I have it now is as a method on Element, which, for example,
> >> you call root.runTheMergeMethod() and it *recursively* scans the Element
> >> (and child Elements) for consecutive Text items and merges them. Should
> >> the
> >> method be recursive, or should it be at the current element only.
> Perhaps
> >> there should be two versions, one is recursive, the other is not.
> >> 3. What should the methods be called?
> >> 4. Should it be accessible through the JDOM Document too, or just the
> root
> >> element?
> >>
> >> Ideas?
> >>
> >> Rolf
> >>
> >> _______________________________________________
> >> To control your jdom-interest membership:
> >> http://www.jdom.org/mailman/options/jdom-interest/[email protected]
> >>
> >
> > _______________________________________________
> > To control your jdom-interest membership:
> > http://www.jdom.org/mailman/options/jdom-interest/[email protected]
>
>
>
> --
> Oliver Ruebenacker, Computational Cell Biologist
> Virtual Cell (http://vcell.org)
> SBPAX: Turning Bio Knowledge into Math Models (http://www.sbpax.org)
> http://www.oliver.curiousworld.org
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/[email protected]
>

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]