[jdom-interest] New realease, Text class... Arghh

phil at triloggroup.com phil at triloggroup.com
Wed Jan 9 07:39:00 PST 2002

As the Text class does not inherit from a common base class with the other elements, I cannot find any reason to get it.
Moreover, we currently have lot of code that checks for explicit String when browsing an element content, and this is
*not* compatible. Do you really

Moreover, it really seems that it is not designed for performance:
=> I agree with A Rosen thread (from last may) who said that using a StringBuffer is not the good thing to do.
First, it is really more frequent to browse a XML document (query, xpath evaluation...) than appending data to an
existing text. And the toString() method always creates a new Object!
Secundo, when do we have to append string to existing one? Mainly in the SAXBuilder, because the parser can split a
string in different character arrays. I circumvent that easily (I uploaded a change to the JDOM authors) by simply
adding a StringBuffer in the SAXBuilder class itself. That StringBuffer was allocated only once and shared by all the
text instances. This was really optimized (OptimizeIt reported a three times performance gain!).
=> It creates an object wrapper for every strings, thus having an unwanted overhead and a stress for the garbage

Now, let's go to the FilteredList.
Ok, that better than the awful PartialList. But they are still pitfalls.
1. We need to store items not in an ArrayList, but in a List inherited from ArrayList, mainly to automatically manage
the parent/child relationship. For example, there's currently a bug in the Element.setText() method, because it does a
content.clear() that does'nt reset the parent property of objects.
2. The getContent() is still unoptimized, while used very often. It can directly return the 'content' list if
implemented as defined in 1.
3. Having direct iterators that deals with the actual list using the Filter class will also performs better. It will be
great to have a getChildrenIterator(Filter) method.
4. The Filter class design mix both the filter capability with other capabilities. Humm...

I'm negative because I'm really both disapointed and upset with that new release.
I want to be positive by saying that I really want to actively participate to that project. I already send proposal to
both Brett & Jason but never got answers

Trilog Group Software

More information about the jdom-interest mailing list