[jdom-interest] Moving elements

Gordon Tyler gordon.tyler at sitraka.com
Thu May 1 08:56:14 PDT 2003


Bradley S. Huffman wrote:
> Jason Hunter writes:
> 
>>2) We could have a new method like this on Element and Document:
>>
>>  List element.getContentDetached()
>>
>>It would return a list of the detached content.  Then you could do this:
>>
>>heading.setContent(anchorList.getContentDetached());
> 
> 
> Definitely +1, but I'd just go ahead and name it removeContent().

I was pondering whether detachContent would be better. It sounds less 
destructive, but the Collection API also uses remove methods which 
return the object(s) removed. So perhaps consistency with standard Java 
APIs is better -- removeContent.

>     List list = anchorList.removeContent();
>     // do the sort
>     heading.setContent(list);
> 
> is very clear about what is actual being done.

Agreed.

Ciao,
Gordon

-- 
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919




More information about the jdom-interest mailing list