Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 87630 invoked from network); 4 Nov 2003 00:10:52 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 4 Nov 2003 00:10:52 -0000 Received: (qmail 67635 invoked by uid 500); 4 Nov 2003 00:10:35 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 67481 invoked by uid 500); 4 Nov 2003 00:10:34 -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 67461 invoked by uid 500); 4 Nov 2003 00:10:34 -0000 Received: (qmail 67458 invoked from network); 4 Nov 2003 00:10:34 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 4 Nov 2003 00:10:34 -0000 Received: (qmail 87590 invoked by uid 1391); 4 Nov 2003 00:10:48 -0000 Date: 4 Nov 2003 00:10:48 -0000 Message-ID: <20031104001048.87589.qmail@minotaur.apache.org> From: jkeyes@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/defaults MessagesBundle.properties DefaultsFactory.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N jkeyes 2003/11/03 16:10:48 Modified: cli/src/java/org/apache/commons/cli2/defaults DefaultsFactory.java Added: cli/src/java/org/apache/commons/cli2/defaults MessagesBundle.properties Log: - i18n - doc Revision Changes Path 1.2 +37 -9 jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/defaults/DefaultsFactory.java Index: DefaultsFactory.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/defaults/DefaultsFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DefaultsFactory.java 2 Nov 2003 22:14:03 -0000 1.1 +++ DefaultsFactory.java 4 Nov 2003 00:10:48 -0000 1.2 @@ -60,20 +60,40 @@ */ package org.apache.commons.cli2.defaults; +import org.apache.commons.cli2.resources.ResourceHelper; + /** * @author John Keyes */ public class DefaultsFactory { + /** i18n */ + private static ResourceHelper resources = + ResourceHelper.getResourceHelper(DefaultsFactory.class); + + /** + * Create a Defaults instance from the specified implementation + * using the specified configuration instance. + * + * @param implName + * a class name for a Defaults implementation + * + * @param configuration + * a configuration instance + * + * @return Defaults + * a Defaults instance + */ public static Defaults createDefaults( final String implName, final Object configuration) { if (implName == null) { - throw new IllegalArgumentException("cannot specify null impl"); + throw new IllegalArgumentException( + resources.getMessage( + "DefaultsFactory.error.impl.name")); } - Class impl = null; try { @@ -83,14 +103,16 @@ .loadClass(implName); } catch (final ClassNotFoundException ctxExp) { - try { impl = DefaultsFactory.class .getClassLoader() .loadClass(implName); } catch (final ClassNotFoundException classExp) { - throw new IllegalArgumentException("could not find impl"); + throw new IllegalArgumentException( + resources.getMessage( + "DefaultsFactory.error.impl.class", + implName)); } } @@ -100,10 +122,16 @@ return defaults; } catch (final InstantiationException exp) { - throw new IllegalArgumentException("inst"); + throw new IllegalArgumentException( + resources.getMessage( + "DefaultsFactory.error.impl.create", + exp.getMessage())); } catch (final IllegalAccessException exp) { - throw new IllegalArgumentException("ill"); + throw new IllegalArgumentException( + resources.getMessage( + "DefaultsFactory.error.impl.access", + exp.getMessage())); } } } 1.1 jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/defaults/MessagesBundle.properties Index: MessagesBundle.properties =================================================================== DefaultsFactory.error.impl.name = Cannot specify a 'null' implementation. DefaultsFactory.error.impl.class = Cannot find implementation class. Reason: {0}. DefaultsFactory.error.impl.create = Cannot instantiate implementation class. Reason: {0}. DefaultsFactory.error.impl.access = Error creating implementation class. Reason: {0}. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org