[jdom-interest] isRootElement issue

Kesav Kumar kesavk at voquette.com
Mon Oct 23 13:35:02 PDT 2000


What is actual meaning of isRootElement? is it just to verify whether the
element is attached to document or does it have any parent or not?

I have test case like this.

I created an Element like
Element root = new Element("Root");
Element child = new Element("Child");
root.addContent(child);

Since root and child doesn't have document associate with them both
child.isRootElement() and root.isRootElement() return false.  

Ideally I feel root.isRootElement should return true sice it has a child.

I propose that we should check for getParent == null for determinig the root
or not.


Kesav Kumar
Software Engineer
Voquette, Inc.
650 356 3740
mailto:kesavk at voquette.com
http://www.voquette.com


-----Original Message-----
From: Jason Hunter [mailto:jhunter at collab.net]
Sent: Monday, October 23, 2000 1:20 PM
To: Kesav Kumar
Cc: 'jdom-interest at jdom.org'
Subject: Re: [jdom-interest] isRootElement issue


isRootElement returns true only if "document != null".  In other words,
only if it directly holds a reference to its document which only the
root will do.  What's wrong with that?  If you have an actual test case
that fails, please send it, making sure of course to test against the
latest first.  :-)

-jh-

Kesav Kumar wrote:
> 
> The method isRootElement() returns true/false on the basis of document.
Is
> it right way of doing?  I think we need to decide whether the element is
> root based on whether the element has any parent.  The reason is If i
create
> a new Element the document is null, after I added child to the new Element
> and query on the child isRootElement it gives true since there is no
> document.  I feel we should check whether getParent() is null or not.
> 
> Any suggestions--
> 
> Kesav Kumar
> Software Engineer
> Voquette, Inc.
> 650 356 3740
> mailto:kesavk at voquette.com
> http://www.voquette.com
> 
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list