ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meta...@apache.org
Subject cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui/core AppContext.java ResourceManager.java
Date Mon, 15 Jan 2001 19:47:27 GMT
metasim     01/01/15 11:47:27

  Modified:    src/antidote/org/apache/tools/ant/gui/core AppContext.java
                        ResourceManager.java
  Log:
  Initial framework for a build-file wizzard.
  
  Revision  Changes    Path
  1.6       +1 -11     jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/AppContext.java
  
  Index: AppContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/AppContext.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AppContext.java	2001/01/12 19:02:34	1.5
  +++ AppContext.java	2001/01/15 19:47:26	1.6
  @@ -63,7 +63,7 @@
    * A container for the state information for the application. Provides
    * a centeralized place to gain access to resources and data.
    * 
  - * @version $Revision: 1.5 $ 
  + * @version $Revision: 1.6 $ 
    * @author Simeon Fitch 
    */
   public class AppContext {
  @@ -159,16 +159,6 @@
       public SelectionManager getSelectionManager() {
           return _selectionManager;
       }
  -
  -    /** 
  -     * Determine if debug mode is turned on.
  -     * 
  -     * @return True if in debug mode, false otherwise.
  -     */
  -    public boolean isDebugOn() {
  -        return _resources.getBoolean("debug");
  -    }
  -
   }
   
   
  
  
  
  1.5       +53 -10    jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/ResourceManager.java
  
  Index: ResourceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/core/ResourceManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ResourceManager.java	2001/01/11 19:24:51	1.4
  +++ ResourceManager.java	2001/01/15 19:47:26	1.5
  @@ -63,7 +63,7 @@
    * Singleton class for accessing various resources by the application.
    * Relies on the resource bundles for resource values.
    *
  - * @version $Revision: 1.4 $ 
  + * @version $Revision: 1.5 $ 
    * @author Simeon H.K. Fitch 
    */
   public class ResourceManager {
  @@ -100,6 +100,19 @@
       }
   
       /** 
  +     * Generate a composit key from the given class and key name.
  +     * 
  +     * @param clazz Class to find resource for.
  +     * @param name Name of the resource.
  +     * @return Composite key.
  +     */
  +    private String getKey(Class clazz, String name) {
  +        name = name == null ? "" : name;
  +
  +        return clazz == null ? name : clazz.getName() + "." + name;
  +    }
  +
  +    /** 
        * Get non-qualified String resource.
        * 
        * @param name Name of the resource.
  @@ -121,7 +134,12 @@
               return null;
           }
   
  -        return _resources.getString(getKey(clazz, name));
  +        try {
  +            return _resources.getString(getKey(clazz, name));
  +        }
  +        catch(MissingResourceException ex) {
  +            return null;
  +        }
       }
   
       /** 
  @@ -156,7 +174,12 @@
           }
   
           if(toTok == null) {
  -            return _resources.getStringArray(key);
  +            try {
  +                return _resources.getStringArray(key);
  +            }
  +            catch(MissingResourceException ex) {
  +                return null;
  +            }
           }
           else {
               StringTokenizer tok = new StringTokenizer(toTok, ", ");
  @@ -201,24 +224,44 @@
               value = _resources.getString(key);
           }
           catch(MissingResourceException ex) {
  -            // Ignore missing resources as they imply false.
  +            return false;
           }
   
           return value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes");
       }
   
       /** 
  -     * Generate a composit key from the given class and key name.
  +     * Get the non-qualified Class type resource for the given key.
        * 
  -     * @param clazz Class to find resource for.
  +     * @param name Name of the resourdce.
  +     * @return Class associated with the key name.
  +     */
  +    public Class getClass(String name) 
  +        throws ClassNotFoundException {
  +        return getClass(null, name);
  +    }
  +
  +    /** 
  +     * Get the Class type resource for the given class and key name.
  +     * 
  +     * @param clazz Class requesting the resource.
        * @param name Name of the resource.
  -     * @return Composite key.
  +     * @return Class associated with the key name.
        */
  -    private String getKey(Class clazz, String name) {
  -        name = name == null ? "" : name;
  +    public Class getClass(Class clazz, String name) 
  +        throws ClassNotFoundException {
   
  -        return clazz == null ? name : clazz.getName() + "." + name;
  +        String key = getKey(clazz, name);
  +        try {
  +            String value = _resources.getString(key);
  +            return Class.forName(value);
  +        }
  +        catch(MissingResourceException ex) {
  +            return null;
  +        }
  +
       }
  +
   
       /** 
        * Generate a localized message using the given set of arguments to 
  
  
  

Mime
View raw message