[jdom-interest] Element Reference from Attribute

Amy Lewis amyzing at talsever.com
Mon Nov 20 18:58:19 PST 2000

On Mon, Nov 20, 2000 at 08:02:39AM -0500, Elliotte Rusty Harold wrote:
>At 10:10 AM -0800 11/19/00, Jason Hunter wrote:
>>>  3. A Node interface or superclass would be a good thing.
>>Could you provide more detail about how you would design it?
>public interface Node {
>   public Node   getParent();
>   public String getValue();
>   // possibly
>   public Document getDocument()
>Possibly we could redefine getParent() like this:
>   public Element   getParent();

+1 on returning Element rather than Node (assuming that Element
implements Node, and that Element can be subclassed freely, which does
seem to be a direction things are now moving).  Reason: you can do more
things with Element, like *get its children*, than you can with Node; a
parent node is *always* an element.

>I'm not sure whether a getChildren() method would be useful:
>   public List getChildren()
>   public NodeList getChildren()

-1.  getChildren() ought to be defined on the objects that *can have*
children, not (confusingly, as DOM defines it) on all objects, even
those that cannot, conceptually, ever have children at all.

BTW, I've got a partial tree implementation that defines a Node
interface, and extends it with "root" "branch" "leaf" interfaces--in
each case, the interface is partially tagging (leaf is simply a way of
discovering that you're at the end of things), but partially truly
extending (for branch, mostly--root extends branch, but mostly as a
tagging interface, to indicate that you're at the other end of things). 

On the other hand, my implementation includes methods for navigating,
which may not at all fit needs here ... think "compilable path
language."  This gives very great power, but potentially great
complexity.  So I don't know if it's at all appropriate for JDOM (it is
what I need).

Amelia A. Lewis          alicorn at mindspring.com          amyzing at talsever.com
Early to bed and early to rise makes a man stupid and blind in the eyes.

More information about the jdom-interest mailing list