Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 60146 invoked from network); 21 Mar 2005 14:22:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Mar 2005 14:22:57 -0000 Received: (qmail 78487 invoked by uid 500); 21 Mar 2005 14:22:49 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 78222 invoked by uid 500); 21 Mar 2005 14:22:47 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: 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 77985 invoked by uid 99); 21 Mar 2005 14:22:47 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from ajax-1.apache.org (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 21 Mar 2005 06:22:45 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (8.12.11/8.12.11) with ESMTP id j2LEMfR8024137 for ; Mon, 21 Mar 2005 15:22:42 +0100 Received: (from nobody@localhost) by ajax.apache.org (8.12.11/8.12.11/Submit) id j2LELAAo023847; Mon, 21 Mar 2005 15:21:10 +0100 Date: Mon, 21 Mar 2005 15:21:10 +0100 Message-Id: <200503211421.j2LELAAo023847@ajax.apache.org> From: bugzilla@apache.org To: commons-dev@jakarta.apache.org Subject: DO NOT REPLY [Bug 34099] - [configuration] Use beanutils for conversions X-Bugzilla-Reason: AssignedTo X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG� RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND� INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=34099 ------- Additional Comments From ittayd@qlusters.com 2005-03-21 15:21 ------- note that for enums, you write the converter only once for all your enums: public class EnumConverter implements Converter { public Object convert(Class classs, Object value) { if (value == null) { throw new ConversionException("No value specified"); } if (value.getClass() == classs) { return value; } String strValue = value.toString(); try { return EnumUtils.getEnum(classs, strValue); } catch (Exception e) { throw new ConversionException("Could not convert " + strValue, e); } } } then, your code is getProperty("foo", MyEnum.class) and you get the enum. also, the enum is the obvious example. generally speaking, i think that writing: public class Foo { private static void Bar b = Config.getConfiguration().getProperty("foo.bar", Bar.class); } is nicer than: private static void Bar b = Bar.fromString(Config.getConfiguration(). getProperty("foo.bar")); moreover, note that the latter form means the property must be a string, but what if the property can be kept as Bar (e.g., a blob in the DB) then, getProperty("foo.bar", Bar.class) is more suitable, since it will just return the property as-is. -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org