[jdom-interest] JDOM JSR

Richard Baldwin baldwin at austin.cc.tx.us
Fri May 18 08:55:06 PDT 2001

Up to this point, I have stayed out of this fray. 
However, here is an example.  

For example, I would like to be able to iterate on the
list returned by getMixedContent() and invoke
getParent() on any item in that list without having to
worry about the actual type of the object.  As it is
now, the string returned by that method is of type
String, which doesn't have a getParent() method.  I
believe that the String should be encapsulated in an
object of an interface type and that object should have
a getParent() method (unless the string doesn't have a

If all of the objects returned by getMixedContent()
were of the same interface type, and that interface
declared the getParent() method, then polymorphism
would apply, and it wouldn't be necessary to worry
about the actual type, or cast to the actual type in
order to learn the parent of any or all of the objects
encapsulated in the list.  

Similarly, any and all methods common to the different
types of objects encapsulated in the list returned by
getMixedContent() could be declared in the interface,
and I could invoke any of those methods on any object
in the list without worrying about the actual type of
the object.

After all, that is how the Collections Framework is
designed.  Why not extend that design to JDOM which
makes very heavy use of the Collections Framework.  

Polymorphism is a wonderful thing once you become
accustomed to using it.

Dick Baldwin

Alex Rosen wrote:
> > The particular implementations that drive this need have typically
> > needed to modify both structure and content of the document being
> > processed, in multiple ways.  The mechanism is often methods with a
> > relatively simple signature (using DOM): Document doSomething(Document, Node)
> Can you provide some examples of this? I've never been able to think of a
> real-world case where you'd want to treat all XML objects (elements,
> attributes, text, PIs, etc) the same. That's not to say that there aren't any!
> But it's just harder to be empathetic about a case that you can't really
> imagine happening. It'd be really helpful to see some real-world examples of
> where you'd have a method that wants to be able to receive all these objects
> and treat them at least mostly equally.
> Alex
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

Richard G. Baldwin (Dick Baldwin)
Home of Baldwin's on-line Java Tutorials

Professor of Computer Studies
Austin Community College
(512) 223-4758 or (512) 250-8682
mailto:baldwin.richard at iname.com  

More information about the jdom-interest mailing list