db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1831026 - in /db/derby/code/trunk: ./ java/build/org/apache/derbyBuild/ java/shared/org/apache/derby/shared/common/error/ java/tools/org/apache/derby/iapi/tools/i18n/ java/tools/org/apache/derby/impl/tools/sysinfo/
Date Sun, 06 May 2018 14:25:48 GMT
Author: rhillegas
Date: Sun May  6 14:25:47 2018
New Revision: 1831026

URL: http://svn.apache.org/viewvc?rev=1831026&view=rev
Log:
DERBY-6945: Misc cleanup related to message localization; commit derby-6945-32-aa-messageLookupCleanup.diff.

Modified:
    db/derby/code/trunk/build.xml
    db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/MessageUtils.java
    db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java

Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/build.xml?rev=1831026&r1=1831025&r2=1831026&view=diff
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Sun May  6 14:25:47 2018
@@ -1405,7 +1405,7 @@
 
     <jar destfile="${derby.jar.dir}/derby.jar"
          basedir="${out.engine.dir}"
-         excludes="**/D_*,**/*.done,**/*Test.class,**/_Suite.class"
+         excludes="**/D_*,**/*.done,**/*Test.class,**/_Suite.class,**/modules.properties"
          compress="true"
          filesonly="true"
          manifest="${derby.jar.dir}/lists/smf.mf">

Modified: db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java?rev=1831026&r1=1831025&r2=1831026&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBundleTest.java Sun May  6
14:25:47 2018
@@ -123,8 +123,6 @@ public class MessageBundleTest {
      * This assumes its available on the classpath
      */
     static void loadMessageBundleIds() throws Exception {
-        ResourceBundle bundle;
-        
         // The messages_*.properties files are split into fifty separate
         // message bundle files.  We need to load each one in turn
         int numBundles = 50;

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/MessageUtils.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/MessageUtils.java?rev=1831026&r1=1831025&r2=1831026&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/MessageUtils.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/error/MessageUtils.java
Sun May  6 14:25:47 2018
@@ -37,6 +37,7 @@ import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
+import org.apache.derby.shared.common.i18n.MessageService;
 import org.apache.derby.shared.common.sanity.SanityManager;
 import org.apache.derby.shared.common.reference.SQLState;
 
@@ -45,7 +46,7 @@ import org.apache.derby.shared.common.re
 
 public class MessageUtils 
 {
-	private static final Locale EN = new Locale("en", "US");
+    private static final Locale EN = new Locale("en", "US");
 	public static final String SQLERRMC_MESSAGE_DELIMITER = new String(new char[] {(char)20,(char)20,(char)20});
 	/** 
 	 * Pointer to the application requester
@@ -223,36 +224,6 @@ public class MessageUtils
 		return hash;
 	}
 
-	/**
-	 * Method to use instead of ResourceBundle.getBundle(). This method acts like ResourceBundle.
-	 * getBundle() but if the resource is not available in the requested locale, default locale

-	 * or base class the one for en_US is returned.
-	 */
-	public static ResourceBundle getBundleWithEnDefault(String resource, Locale locale) {
-
-		try {
-			return ResourceBundle.getBundle(resource, locale);
-		} catch (MissingResourceException mre) {
-
-			// This covers the case where neither the
-			// requested locale or the default locale
-			// have a resource.
-
-			return ResourceBundle.getBundle(resource, EN);
-		}
-	}
-
-	/** 
-	 * 
-	 */
-    public static ResourceBundle getBundleForLocale(Locale locale, String msgId) {
-		try {
-			return MessageUtils.getBundleWithEnDefault("org.apache.derby.loc.m"+hashString50(msgId),
locale);
-		} catch (MissingResourceException mre) {
-		}
-		return null;
-	}
-
 	public static String formatMessage(ResourceBundle bundle, String messageId, Object[] arguments,
boolean lastChance) {
 
 		if (arguments == null)
@@ -366,7 +337,8 @@ public class MessageUtils
         }
 
         try {
-            msg[0] = formatMessage(getBundleForLocale(locale, messageId), messageId, arguments,
true);
+            msg[0] = formatMessage
+              (MessageService.getBundleForLocale(locale, messageId), messageId, arguments,
true);
             rc[0] = 0;
             return;
         } catch (MissingResourceException mre) {
@@ -374,7 +346,8 @@ public class MessageUtils
             // most likely it does exist in our fake base class _en, so try that.
         } catch (ShutdownException se) {
         }
-        msg[0] = formatMessage(getBundleForLocale(EN, messageId), messageId, arguments, false);
+        msg[0] = formatMessage
+          (MessageService.getBundleForLocale(EN, messageId), messageId, arguments, false);
         rc[0] = 0;
     }
     
@@ -389,14 +362,15 @@ public class MessageUtils
         String locMsg = null;
 
         try {
-            locMsg = formatMessage(getBundleForLocale(locale, messageId), messageId, args,
true);
+            locMsg = formatMessage
+              (MessageService.getBundleForLocale(locale, messageId), messageId, args, true);
             return locMsg;
         } catch (MissingResourceException mre) {
             // message does not exist in the requested locale
             // most likely it does exist in our fake base class _en, so try that.
         } catch (ShutdownException se) {
         }
-        locMsg = formatMessage(getBundleForLocale(EN, messageId), messageId, args, false);
+        locMsg = formatMessage(MessageService.getBundleForLocale(EN, messageId), messageId,
args, false);
         return locMsg;
     }
 }

Modified: db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java?rev=1831026&r1=1831025&r2=1831026&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
(original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedResource.java
Sun May  6 14:25:47 2018
@@ -39,6 +39,7 @@ import java.util.Locale;
 import java.util.ResourceBundle;
 import java.util.StringTokenizer;
 
+import org.apache.derby.shared.common.i18n.MessageService;
 
 public final class LocalizedResource  implements java.security.PrivilegedAction<String>
{
 
@@ -169,16 +170,7 @@ public final class LocalizedResource  im
 		if (res != null){
 			return;
 		}
-		if ( locale == null || locale.toString().equals("none") ){
-			res = ResourceBundle.getBundle(messageFileName);
-		}
-		else
-		try {
-			res = ResourceBundle.getBundle(messageFileName,locale);
-		}
-		catch(java.util.MissingResourceException e){
-			res = ResourceBundle.getBundle(messageFileName,Locale.ENGLISH);
-		}
+        res = MessageService.getBundleWithEnDefault(messageFileName, locale);
 	}
 	private void initMaxSizes2(){
 		dateSize = 0;

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java?rev=1831026&r1=1831025&r2=1831026&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java Sun May 
6 14:25:47 2018
@@ -34,7 +34,6 @@ import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.util.Locale;
 import java.util.MissingResourceException;
-import java.util.ResourceBundle;
 import java.util.StringTokenizer;
 import java.io.File;
 import java.util.zip.ZipFile;



Mime
View raw message