ASF Bugzilla – Attachment 23424 Details for
Bug 46933
Using Java 1.5 in StringManager
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
update method to java 1.5
StringManager.diff (text/plain), 4.07 KB, created by
Jens Kapitza
on 2009-03-27 15:34:14 UTC
(
hide
)
Description:
update method to java 1.5
Filename:
MIME Type:
Creator:
Jens Kapitza
Created:
2009-03-27 15:34:14 UTC
Size:
4.07 KB
patch
obsolete
>Index: java/org/apache/tomcat/util/res/StringManager.java >=================================================================== >--- java/org/apache/tomcat/util/res/StringManager.java (Revision 759377) >+++ java/org/apache/tomcat/util/res/StringManager.java (Arbeitskopie) >@@ -131,107 +131,26 @@ > * @param args > */ > >- public String getString(String key, Object[] args) { >+ public String getString(final String key,final Object... args) { > String iString = null; > String value = getString(key); >+ if( value==null ) value=key; > >- // this check for the runtime exception is some pre 1.1.6 >- // VM's don't do an automatic toString() on the passed in >- // objects and barf out >- >- try { >- // ensure the arguments are not null so pre 1.2 VM's don't barf >- if(args==null){ >- args = new Object[1]; >+ Object[] nonNullArgs = args == null ? new Object[1] : args; >+ for (int i=0; i < args.length; i++) { >+ if (args[i] == null) { >+ if (nonNullArgs == args){ >+ nonNullArgs = args.clone(); >+ } >+ nonNullArgs[i] = "null"; > } >- >- Object[] nonNullArgs = args; >- for (int i=0; i<args.length; i++) { >- if (args[i] == null) { >- if (nonNullArgs==args){ >- nonNullArgs=args.clone(); >- } >- nonNullArgs[i] = "null"; >- } >- } >- if( value==null ) value=key; >- MessageFormat mf = new MessageFormat(value); >- mf.setLocale(locale); >- iString = mf.format(nonNullArgs, new StringBuffer(), null).toString(); >- } catch (IllegalArgumentException iae) { >- StringBuffer buf = new StringBuffer(); >- buf.append(value); >- for (int i = 0; i < args.length; i++) { >- buf.append(" arg[" + i + "]=" + args[i]); >- } >- iString = buf.toString(); > } >+ MessageFormat mf = new MessageFormat(value); >+ mf.setLocale(locale); >+ iString = mf.format(nonNullArgs, new StringBuffer(), null).toString(); > return iString; > } > >- /** >- * Get a string from the underlying resource bundle and format it >- * with the given object argument. This argument can of course be >- * a String object. >- * >- * @param key >- * @param arg >- */ >- >- public String getString(String key, Object arg) { >- Object[] args = new Object[] {arg}; >- return getString(key, args); >- } >- >- /** >- * Get a string from the underlying resource bundle and format it >- * with the given object arguments. These arguments can of course >- * be String objects. >- * >- * @param key >- * @param arg1 >- * @param arg2 >- */ >- >- public String getString(String key, Object arg1, Object arg2) { >- Object[] args = new Object[] {arg1, arg2}; >- return getString(key, args); >- } >- >- /** >- * Get a string from the underlying resource bundle and format it >- * with the given object arguments. These arguments can of course >- * be String objects. >- * >- * @param key >- * @param arg1 >- * @param arg2 >- * @param arg3 >- */ >- >- public String getString(String key, Object arg1, Object arg2, >- Object arg3) { >- Object[] args = new Object[] {arg1, arg2, arg3}; >- return getString(key, args); >- } >- >- /** >- * Get a string from the underlying resource bundle and format it >- * with the given object arguments. These arguments can of course >- * be String objects. >- * >- * @param key >- * @param arg1 >- * @param arg2 >- * @param arg3 >- * @param arg4 >- */ >- >- public String getString(String key, Object arg1, Object arg2, >- Object arg3, Object arg4) { >- Object[] args = new Object[] {arg1, arg2, arg3, arg4}; >- return getString(key, args); >- } > // -------------------------------------------------------------- > // STATIC SUPPORT METHODS > // --------------------------------------------------------------
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 46933
: 23424 |
23550