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