[jdom-interest] Sorting Children, Collections.sort, ComodificationException, etc., etc.

Bradley S. Huffman hip at a.cs.okstate.edu
Mon Sep 23 12:21:39 PDT 2002


That would work, but IMHO it still be better for setContent to return
something more useful then the parent.  To use setContent you have to
already have the parent.

Guess this would be a good example for ELH's "Pinciple of Least Surpise".
Here I had a hand in the current implementation and was still bitten by
it:)

Brad

bob mcwhirter writes:

> 
> List contentList = new ArrayList( element.getContext() );
> 
> element.setContent( null );
> 
> 	-bob
> 
> 
> On Mon, 23 Sep 2002, Bradley S. Huffman wrote:
> 
> > Damn, your right :( I'm beginning to really hate "live" lists. What I reall
> y
> > want is setContent() to return a List of the old children detached instead
> > "this element modified".
> > 
> > Brad
> > 
> > Gordon Tyler writes:
> > 
> > > Bradley S. Huffman wrote:
> > > 
> > > > public static void sortContent(Element element, Comparator comparator) 
> {
> > > >     // Get a List of the current children
> > > >     List contentList = element.getContent();
> > > > 
> > > >     // Temporarily remove all content
> > > >     element.setContent(null);           
> > > 
> > > But since the list returned by element.getContent() is a "live" list, 
> > > wouldn't this statement empty contentList?
> > > 
> > > Ciao,
> > > Gordon
> > > 
> > > -- 
> > > Gordon Tyler
> > > Software Developer, R&D
> > > Sitraka -- Performance is Mission Critical
> > > 
> > _______________________________________________
> > 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@yourhost
> .com



More information about the jdom-interest mailing list