[jdom-interest] Subclassing Element vs Element Context
dmc at clearlight.com
Sat Nov 4 16:16:00 PST 2000
Jehoiada Bernard wrote:
> For applications that navigate the document as a simple tree of Elements,
> how about simply being able to attach contextual information to an element?
> e.g., element.setContext(Object); You could then color the tree with any
> you wish without subclassing Element. This seems like a low impact change to
> current design.
I somewhat agree with this, this is like Swing's "setUserObject()" on
TreeNodes. That would be pretty useful and its not as controversial as
the other proposed enhancements to JDOM.
Its not *quite* as nice, though, as knowing the object you are dealing
with, since typical code would say:
Element myElement = rootElement.getChild("foo");
MyCustomObject o = (MyCustomObject) myElement.getUserObject();
MyCustomElement e = (MyCustomElement) rootElement.getChild("foo");
But frankly, your approach does solve the problem, and it does so
without any significant impact that I can think of.
More information about the jdom-interest