[jdom-interest] Content as a Text Node (was JDOM JSR)

Brett McLaughlin brett at newInstance.com
Fri May 18 12:52:09 PDT 2001

> Brett McLaughlin wrote:
> >
<snip subject="Text node instead of String" />

> I have no fundamental objections to this approach.  It's something we
> considered when Bob was looking for parentage for XPath, but we didn't
> pursue it because he found alternate approaches.
> My two concerns with having a Text class are:
> 1) Addition of another class and the loss of one aspect of JDOM that has
> always been very Java-friendly.  People "get it" when they hear "JDOM
> uses String instead of some funky Text class".  That direct message is
> lost with the addition of a Text class.

Agreed. However, I think that we can be careful in how we say that; for
instance, saying that "all element content is stored as a Text node" is not
good. However, we can say (truthfully) "You can directly get an element's
content as a String, without having to deal with a Text node class." This is
the advantage people want, I think; the detail of how it's stored
internally, or that you CAN get it in a Text node, is really irrelevant to
most people, I think.

> 2) Memory consumption.  It depends on your JVM but I hear each object
> adds about 40 bytes to the heap, and having the wrapper would be another
> object per string.

Yup. And in the case of mixed content, you could potentially have more than
one (full disclosure hat on). It interests me to put a simple implementation
of this together and run some perf. tests with JProbe and such. Right now,
we're all probably only going to be able to guess at the change in
performance and memory. It's nice if we can to actually do some concrete
comparison, no?

> It's probably worth it tho for the reasons stated earlier.  And we'll
> get some goodness with CDATA being able to be a Text subclass.  (I think
> it's probably better to keep a CDATA class rather than have a flag on
> Text.)

I tend to agree with you here, as well. Keeps things simpler.

I'll see if I have time to try this out this weekend...


> Other thoughts?
> -jh-

More information about the jdom-interest mailing list