[jdom-interest] (no subject)

Jason Hunter jhunter at acm.org
Thu May 29 08:35:44 PDT 2003


We put getParent() in Child because children have parents.  Parents 
don't necessarily.  If the call were in Parent, only Document and 
Element would have the call.  We'd probably have to put it in both 
places to enable the method chaining as you'd like.  That's just odd.

Hmm, I'm still thinking we need a method like getParentElement(). 
Returns the parent Element or null if root or unattached.  It could be 
added to Child.  Then you could call 
getParentElement().getParentElement()...

Then all b9 getParent() calls can be moved to getParentElement() calls 
in b10.  I think getParent() has to continue returning a Parent just to 
be sensible.

Thoughts?

-jh-


Robertson, Jason wrote:
> So, just wondering, why doesn't Parent have a getParent() method? 
> 
> It seems like this would be reasonable given XML's hierarchical layout, i.e.
> if you have a parent it's only one parent so getParent() would be
> unambiguous. Comparatively it doesn't make sense for Child to have something
> like getChild() since going down the tree is much more complex.
> 
> In this one tool I've written I have quite a few places where I do, for
> example
> 
> getParent().getParent().getParent().getAttribute()
> 
> and of course I could replace it with XPath, or this:
> 
> ((Element) ((Child) ((Child)
> getParent()).getParent()).getParent()).getAttribute()
> 
> but this looks kinda funny and it just feels like you should be able to
> string getParent() calls together directly. I guess you'll still have to
> cast an Element in the end, but one cast is better than several.
> 
> Jason
> 
> p.s. I have approx 1 month of jdom-interest locally, and I searched that but
> didn't find anything. If this has been previously discussed let me know and
> I'll hit the archives.
> 
> -----Original Message-----
> From: Bradley S. Huffman [mailto:hip at a.cs.okstate.edu]
> Sent: Tuesday, May 27, 2003 4:47 PM
> To: bob mcwhirter
> Cc: jdom-interest at jdom.org
> Subject: Re: [jdom-interest] (no subject) 
> 
> 
> At one time I think I had a patch to jaxen that took care of this. I'll
> look for it when I get home, make sure it still works, and send it in for
> jdom-contrib.
> 
> Brad
> 
> bob mcwhirter writes:
> 
> 
>>Yah, fwiw, this broke jaxen and jxpath and their support of JDOM,
>>according to gump.  I haven't gotten jaxen fixed yet.
>>
>>	-bob
>>
>>
>>On Tue, 27 May 2003, Jason Hunter wrote:
>>
>>
>>>>elementMatched(String path, Element e) {
>>>>  String parentName =
> 
> e.getParent().getParent().getAttributeValue("name")
> 
>>;
>>
>>>>}
>>>>
>>>>This no longer works because getParent() returns a Parent instead of
> 
> an
> 
>>>>Element. Is there a way around this?
>>>
>>>Cast it?
>>>
>>>-jh-
>>>
>>>
>>>_______________________________________________
>>>To control your jdom-interest membership:
>>>
> 
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourho
> 
>>st.com
>>
>>--
>>Bob McWhirter        bob at werken.com
>>The Werken Company   http://werken.com/
>>
>>_______________________________________________
>>To control your jdom-interest membership:
>>
> 
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
> t
> 
>>.com
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
> t.com
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
> 




More information about the jdom-interest mailing list