You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by me...@apache.org on 2001/03/23 23:55:38 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/jasper Constants.java

melaquias    01/03/23 14:55:38

  Modified:    src/share/org/apache/jasper Constants.java
  Log:
  Refactored to use org.apache.tomcat.util.res.StringManager for String Resource retrieval.   [i.e. maximize code re-use].
  
  affects:
  Jasper message strings in org.apache.jasper.resources no longer stored in "messages.properties", but rather "LocalStrings.properties" as required by StringManager.
  
  Revision  Changes    Path
  1.18      +8 -34     jakarta-tomcat/src/share/org/apache/jasper/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/Constants.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Constants.java	2001/03/09 22:26:12	1.17
  +++ Constants.java	2001/03/23 22:55:37	1.18
  @@ -61,9 +61,11 @@
   import java.text.MessageFormat;
   
   import org.apache.tomcat.util.log.Log;
  +import org.apache.tomcat.util.res.StringManager;
    
   /**
  - * Some constants and other global data that are used by the compiler and the runtime.
  + * Some constants and other global data that are used by the compiler
  + * and the runtime.
    *
    * @author Anil K. Vijendran
    * @author Harish Prabandham
  @@ -186,15 +188,11 @@
       /**
        * This is where all our error messages and such are stored. 
        */
  -    private static ResourceBundle resources;
  +    private static StringManager resources;
       
       private static void initResources() {
  -	try {
  -	    resources =
  -		ResourceBundle.getBundle("org.apache.jasper.resources.messages");
  -	} catch (MissingResourceException e) {
  -	    throw new Error("Fatal Error: missing resource bundle: "+e.getClassName());
  -	}
  +        resources = StringManager.getManager(
  +                    "org.apache.jasper.resources");
       }
   
       /**
  @@ -209,34 +207,10 @@
        * Format the string that is looked up using "key" using "args". 
        */
       public static final String getString(String key, Object[] args) {
  -        if (resources == null) 
  +        if(resources==null){
               initResources();
  -        
  -        try {
  -            String msg = resources.getString(key);
  -            if (args == null)
  -                return msg;
  -	    if( msg==null ) {
  -		//System.out.println("Can't find resource for " + key );
  -		return key;
  -	    }
  -            MessageFormat form = new MessageFormat(msg);
  -	    // JDK1.1 will throw NullPointer if args[0] == null
  -	    // JDK1.2+ will work fine.
  -	    
  -	    //System.out.println(" XXX " + msg + " "+key + " " +args.length );
  -	    if( args.length >0 ) {
  -		for( int i=0; i< args.length; i++ ) {
  -		    if( args[i]==null ) {
  -			//System.out.println("Null argument " +msg + " " + key);
  -			return msg;
  -		    }
  -		}
  -	    }
  -            return form.format(args);
  -        } catch (MissingResourceException ignore) {
  -            throw new Error("Fatal Error: missing resource: "+ignore.getClassName());
           }
  +        return resources.getString(key,args);
       }
   
       /**