commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jke...@apache.org
Subject cvs commit: jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/defaults MessagesBundle.properties DefaultsFactory.java
Date Tue, 04 Nov 2003 00:10:48 GMT
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


Mime
View raw message