[jdom-interest] children as List

David W. Smiley dsmiley at mitre.org
Fri Sep 1 12:29:22 PDT 2000

>         How about creating a tagging interface (like Serializable) instead
> of 
> unifying the class hierarchy? This way, anything that wants to operate on 
> just JDOM nodes (and not just a specific class of JDOM nodes) can be sure 
> it's got one by testing for the tag. And it provides a useful place to put 
> whatever functionality may be common (such as getParent()) if we do decide 
> to unify the hierarchy.

	This sounds good to me; but the problem is that "String" is being used
as a node and therefore can't implement anything.  This could be solved
with a "Text" class that did implement "Node" but unfortunately the
powers that be (Brett, Elliott & the gang) do not like this.
	_I_ do think that a "Text" class would be a good idea; especially if
Element.getContent() would be defined to return the String value of the
Text if the content is a Text.  That looks like a good compromise to me
and adds type safety.  And instead of adding "Object" to an Element, you
add "Node".  That add method could be overloaded to accept a String
which will be converted to a Text Node.  Damn this sounds like a good
idea!  I can think a few methods that Node would have: toSerializedForm,
getParent, and perhaps getRootElement.  Even if it has no methods at
all, a Node class is a good idea.  Attributes should probably not
implement node even though they have a parent.

-- David Smiley

More information about the jdom-interest mailing list