Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 84147 invoked from network); 29 Jan 2006 18:24:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Jan 2006 18:24:14 -0000 Received: (qmail 57807 invoked by uid 500); 29 Jan 2006 18:24:12 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 57783 invoked by uid 500); 29 Jan 2006 18:24:12 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 57772 invoked by uid 99); 29 Jan 2006 18:24:12 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Jan 2006 10:24:12 -0800 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=HTML_00_10,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of mblum42@gmail.com designates 64.233.162.199 as permitted sender) Received: from [64.233.162.199] (HELO zproxy.gmail.com) (64.233.162.199) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Jan 2006 10:24:11 -0800 Received: by zproxy.gmail.com with SMTP id 9so975608nzo for ; Sun, 29 Jan 2006 10:23:50 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=Dj4WYDbdeR+ghwNWAT37EeWpGsLwFPevqLhCJR9BK51jIcBD7YZAisqD7yjAjqsDv/ct4R+XZ5O9HOozTfbQEogzFNFnVghCobBZVhNW9imMKhYSxHvRsmzsrd5psJKZKt0/720H87ET8jxA7XF/bUp4tZX2ad+BL/HQY3OZTP8= Received: by 10.36.48.1 with SMTP id v1mr4139660nzv; Sun, 29 Jan 2006 10:23:50 -0800 (PST) Received: by 10.36.115.20 with HTTP; Sun, 29 Jan 2006 10:23:50 -0800 (PST) Message-ID: Date: Sun, 29 Jan 2006 13:23:50 -0500 From: Matt Blum To: commons-dev@jakarta.apache.org Subject: [collections] New utility methods for CollectionUtils & ListUtils MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2565_32180689.1138559030674" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_2565_32180689.1138559030674 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I'm new to the commons-dev list, but I've participated a bit in the MyFaces list and, a while ago, in the Struts list. I have several methods that I think would make good additions to the Common= s Collections CollectionUtils and ListUtils classes, and I wanted to find out= : 1. Whether there was interest in them; 2. If so, how I go about submitting a patch. The proposed CollectionUtils method is currently called cloneCollection, bu= t could be called deepClone. It takes any Collection as a parameter, and attempts to create a clone of it and every object contained within it. It tries a couple of different processes to do this, starting with using reflection to find the objects' clone method; if they don't have such a method but are Serializable, it uses Commons Lang SerializationUtils' clone method to clone them. If it can't do that, either, it will just copy by reference. It will recursively iterate through any sub-Collections as well= , meaning that circular references will cause it to generate a stack overflow. I've found it to be very useful. The main proposed ListUtils method is simply called move, and takes a List, an index, and a distance as parameters. It will move the element in the List at the specified index the specified distance, which can either be positive or negative. It will wrap around, so that, in a List of length three (say), moving an element a distance of -2 would have the same effect as moving it 1. It will throw IndexOutOfBoundsException, as you'd expect, if the specified index is out of range. I have another proposed ListUtils method, called removeNulls, which as you'= d expect simply removes nulls from a list. If there's interest, please let me know, and if someone who knows more than I do about the process could also please let me know what the best way is t= o submit a patch. Thanks! -Matt ------=_Part_2565_32180689.1138559030674--