db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1495023 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/ tools/org/apache/derby/iapi/tools/i18n/ tools/org/apache/derby/impl/tools/sysinfo/ tools/org/apache/derby/tools/
Date Thu, 20 Jun 2013 14:37:46 GMT
Author: kahatlen
Date: Thu Jun 20 14:37:46 2013
New Revision: 1495023

URL: http://svn.apache.org/r1495023
Log:
DERBY-6262: Simplify message-generating methods using varargs

Reduce number of methods that format messages in tools classes.

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.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
    db/derby/code/trunk/java/tools/org/apache/derby/tools/SignatureChecker.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=1495023&r1=1495022&r2=1495023&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Thu Jun 20 14:37:46 2013
@@ -3496,11 +3496,12 @@ public final class NetworkServerControlI
      */
     private String localizeMessage(String msgProp, LocalizedResource localLangUtil, String
[] args)
     {
-        String locMsg = null;
+        Object[] argMsg = null;
+
         //check if the argument is a property
         if (args != null)
         {
-            String [] argMsg = new String[args.length];
+            argMsg = new String[args.length];
             for (int i = 0; i < args.length; i++)
             {
                 if (isMsgProperty(args[i]))
@@ -3508,27 +3509,9 @@ public final class NetworkServerControlI
                 else
                     argMsg[i] = args[i];
             }
-            switch (args.length)
-            {
-                case 1:
-                    locMsg = localLangUtil.getTextMessage(msgProp, argMsg[0]);
-                    break;
-                case 2:
-                    locMsg = localLangUtil.getTextMessage(msgProp, argMsg[0], argMsg[1]);
-                    break;
-                case 3:
-                    locMsg = localLangUtil.getTextMessage(msgProp, argMsg[0], argMsg[1],
argMsg[2]);
-                    break;
-                case 4:
-                    locMsg = localLangUtil.getTextMessage(msgProp, argMsg[0], argMsg[1],
argMsg[2], argMsg[3]);
-                    break;
-                default:
-                    //shouldn't get here
-            }
         }
-        else
-            locMsg = localLangUtil.getTextMessage(msgProp);
-        return locMsg;
+
+        return localLangUtil.getTextMessage(msgProp, argMsg);
     }
     /**
      * Determine type of message

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=1495023&r1=1495022&r2=1495023&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
Thu Jun 20 14:37:46 2013
@@ -269,25 +269,6 @@ public final class LocalizedResource  im
 	    out = new LocalizedOutput(o, encoding);
 	    return out;
 	}
-	public String getTextMessage(String key ) {
-        return getTextMessage(key, new Object[0]);
-	}
-	public String getTextMessage(String key, Object o){
-			Object [] att=new Object[] {o};
-			return getTextMessage(key,att);
-	}
-	public String getTextMessage(String key, Object o1, Object o2){
-			Object [] att=new Object[] {o1,o2};
-			return getTextMessage(key,att);
-	}
-	public String getTextMessage(String key, Object o1, Object o2, Object o3){
-			Object [] att=new Object[] {o1,o2,o3};
-			return getTextMessage(key,att);
-	}
-	public String getTextMessage(String key, Object o1, Object o2, Object o3, Object o4){
-			Object [] att=new Object[] {o1,o2,o3,o4};
-			return getTextMessage(key,att);
-	}
 	private Locale getNewLocale(String locStr){
 			String l="", r="", v="";
 			StringTokenizer st;
@@ -306,7 +287,7 @@ public final class LocalizedResource  im
 				return null;
 			}
 	}
-	public String getTextMessage(String key, Object [] objectArr) {
+    public String getTextMessage(String key, Object... objectArr) {
 		if (res == null){
 			setResource();
 		}
@@ -479,21 +460,9 @@ public final class LocalizedResource  im
 	public boolean isLocalized(){
 		return getInstance().enableLocalized;
 	}
-	public static String getMessage(String key){
-		return getInstance().getTextMessage(key);
-	}
-	public static String getMessage(String key, Object o1){
-		return getInstance().getTextMessage(key,o1);
-	}
-	public static String getMessage(String key, Object o1, Object o2){
-		return getInstance().getTextMessage(key,o1,o2);
-	}
-	public static String getMessage(String key, Object o1, Object o2, Object o3){
-		return getInstance().getTextMessage(key,o1,o2,o3);
-	}
-	public static String getMessage(String key, Object o1, Object o2, Object o3, Object o4){
-		return getInstance().getTextMessage(key,o1,o2,o3,o4);
-	}
+    public static String getMessage(String key, Object... args) {
+        return getInstance().getTextMessage(key, args);
+    }
 	public static LocalizedOutput OutputWriter(){
 		return getInstance().out;
 	}

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=1495023&r1=1495022&r2=1495023&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 Thu Jun 20
14:37:46 2013
@@ -1079,26 +1079,7 @@ public static void getMainInfo (java.io.
 	** Message handling
 	*/
 
-	public static String getTextMessage(String msgId) {
-		return getCompleteMessage(msgId, new Object[0]);
-	}
-	public static String getTextMessage(String msgId, Object a1) {
-
-		return getCompleteMessage(msgId, new Object[] {a1});
-	}
-	public static String getTextMessage(String msgId, Object a1, Object a2) {
-		return getCompleteMessage(msgId, new Object[] {a1, a2});
-	}
-	public static String getTextMessage(String msgId, Object a1, Object a2, Object a3) {
-		return getCompleteMessage(msgId, new Object[] {a1, a2, a3});
-	}
-	public static String getTextMessage(String msgId, Object a1, Object a2, Object a3, Object
a4) {
-		return getCompleteMessage(msgId, new Object[] {a1, a2, a3, a4});
-	}
-
-	/**
-	 */
-	public static String getCompleteMessage(String msgId, Object[] arguments) {
+    public static String getTextMessage(String msgId, Object... arguments) {
         return LOCALIZED_RESOURCE.getTextMessage(msgId, arguments);
 	}
 

Modified: db/derby/code/trunk/java/tools/org/apache/derby/tools/SignatureChecker.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/tools/SignatureChecker.java?rev=1495023&r1=1495022&r2=1495023&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/tools/SignatureChecker.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/tools/SignatureChecker.java Thu Jun 20
14:37:46 2013
@@ -522,27 +522,11 @@ public class SignatureChecker
     }
 
     /**
-     * Format a localizable message with 0 args.
+     * Format a localizable message.
      */
-    private static  String  formatMessage( String key )
+    private static String formatMessage(String key, Object... args)
     {
-        return getMessageFormatter().getTextMessage( key );
-    }
-    
-    /**
-     * Format a localizable message with 1 arg.
-     */
-    private static  String  formatMessage( String key, String arg0 )
-    {
-        return getMessageFormatter().getTextMessage( key, arg0 );
-    }
-    
-    /**
-     * Format a localizable message with 2 args.
-     */
-    private static  String  formatMessage( String key, String arg0, String arg1 )
-    {
-        return getMessageFormatter().getTextMessage( key, arg0, arg1 );
+        return getMessageFormatter().getTextMessage(key, args);
     }
     
     /**



Mime
View raw message