[jdom-interest] ContentList

Ashley Martens martensa at asconline.com
Thu Oct 20 09:30:44 PDT 2005


I see your point.
	List sortedList = new ArrayList(list);
	list.clear();
	Collections.sort(sortedList, comparator);
	list.addAll(sortedList);

> -----Original Message-----
> From: Jason Hunter [mailto:jhunter at xquery.com]
> Sent: Thursday, October 20, 2005 3:05 AM
> To: Ashley Martens
> Cc: jdom-interest at jdom.org
> Subject: Re: [jdom-interest] ContentList
> 
> 
> That patch wouldn't work because it'd let the same element be 
> added to 
> its parent twice concurrently.  That'd cause real problems 
> with XPaths 
> like following-sibling::*.  The key to sorting is to copy the 
> nodes out 
> of the list, remove them in bulk from their parent using 
> something like 
> e.getContent().clear(), sort them, then reattach them in bulk using 
> something like e.addContent(sortedList).
> 
> -jh-
> 
> Ashley Martens wrote:
> 
> > I was trying to sort a content list with 1.0 release and 
> ran into an exception which I thought was incorrect. Could 
> someone look over this patch to org.jdom.ContentList [$Id: 
> ContentList.java,v 1.39 2004/02/28 03:30:27 jhunter Exp $] 
> and commit if it makes sense.
> > 
> > 217c217
> > <             else {
> > ---
> > 
> >>          else if (p != parent) { 
> > 
> > 
> > E-Mail Confidentiality Notification
> > 
> > -----------------------------------
> > 
> > This e-mail message (and any associated files) contains 
> information from Associated Software Consultants (ASC), Inc. 
> and is intended only for the use of the individual or entity 
> to which it is addressed and may contain information that is 
> confidential, subject to copyright or constitutes a trade 
> secret. If you are not the intended recipient you are hereby 
> notified that any dissemination, copying or distribution of 
> this message, or files associated with this message, is 
> strictly prohibited. If you have received this message in 
> error, please notify us immediately by replying to the 
> message and deleting it from your computer. Messages sent to 
> and from us may be monitored.
> > 
> > _______________________________________________
> > To control your jdom-interest membership:
> > 
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@you
rhost.com
> 



More information about the jdom-interest mailing list