Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 92748 invoked from network); 14 May 2007 16:59:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 May 2007 16:59:19 -0000 Received: (qmail 87067 invoked by uid 500); 14 May 2007 16:59:23 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 87000 invoked by uid 500); 14 May 2007 16:59:23 -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 38655 invoked by uid 99); 14 May 2007 14:00:22 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of sunnanpuppan@gmail.com designates 66.249.92.171 as permitted sender) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=IU2Rrhw9NaPdDMrriJZOnQvkuy/fce7DTty/5Y86VAZcbpwJmUHu8d3v7TDTk2rq6fWEq30Hu3yEKjb2eCWrvljaiNnWbJedNaztPdeFxZoQqA4MTOtWyB0ZnR9My1WO1itIsT7NMh2L1Duk+ZPSVW8oXET7VRAltNVLEL2mzek= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=g6vsTbTHgiirclM8n3U6j1N9bupOnQHjBRPX1pRbpa18cmbvRBV9GLzGcWHKtgvtrWXuRQfiVOY9Spw29BwdTZoY54mgQmST5gQ+LbnjQ2rdbYboSVVmdIxF1bVbQY20l8NXwmdcq6RE5tOJbX3CW+VJ6idRDZush9pGloJ5yyg= Message-ID: Date: Mon, 14 May 2007 15:59:52 +0200 From: Sunnan Sender: sunnanpuppan@gmail.com To: commons-dev@jakarta.apache.org Subject: Suggestion for MapUtils MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 2f7f0fffd35d4423 X-Virus-Checked: Checked by ClamAV on apache.org Hi, I'm relatively new to Java but I'm already a big fan of the Jakarta Commons. I was wondering, is there something like the following already in Commons, be it Lang or Collections? (I'm thinking ...collections.MapUtils.) /** * Creates a new Map containing some of the keys from another Map, * optionally renamed. *

* @param orig the map to get keys from * @param keys the new-key->old-key map */ public static HashMap renameKeys (Map orig, Map keys) { HashMap ret = new HashMap(); for (Object o : keys.entrySet()) { ret.put(((Entry)o).getKey(), orig.get(((Entry)o).getValue())); } return ret; } I typically use it when I have a map (often a BeanMap) and I need the same values, but with other key names (in order to automatically populate an LDAPEntry or some XML). (I usually use String key names.) If there's nothing like this already, I'd like to submit this. I'm open to improving it, of course. Thangs for your time, Sunnan --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org