empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1614282 - /empire-db/trunk/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java
Date Tue, 29 Jul 2014 08:33:23 GMT
Author: doebele
Date: Tue Jul 29 08:33:23 2014
New Revision: 1614282

URL: http://svn.apache.org/r1614282
Log:
EMPIREDB-206

Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java?rev=1614282&r1=1614281&r2=1614282&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java
Tue Jul 29 08:33:23 2014
@@ -46,7 +46,7 @@ public class EmpireException extends Run
             if (pattern==null)
                 pattern=errType.getMessagePattern();
             // init format args
-            Object[] formatArgs = (Object[])params;
+            Object[] formatArgs = params;
             // Check parameter count
             int patParamCount = errType.getNumParams();
             int paramCount = (params!=null) ? params.length : 0;            
@@ -59,24 +59,27 @@ public class EmpireException extends Run
             }
             // more params than expected
             else if (paramCount>patParamCount)
-            {   // Wildcard for the rest
+            {   // check for wildcard
                 if (pattern.contains("{*}")) 
                 {   pattern = pattern.replace("{*}", "{"+String.valueOf(patParamCount)+"}");
                     patParamCount++;
                 }
                 // Build new array
-                formatArgs = new String[patParamCount];
-                int i=0;
-                for (; i<patParamCount-1; i++)
-                    formatArgs[i]=params[i];
-                // Build a array for the rest
-                StringBuilder b = new StringBuilder();
-                for (;i<paramCount;i++)
-                {   if (b.length()>0)
-                        b.append(", ");
-                    b.append(String.valueOf(params[i]));
+                if (patParamCount>0)
+                {	// reduce number of arguments
+	                formatArgs = new String[patParamCount];
+	                int i=0;
+	                for (; i<patParamCount-1; i++)
+	                    formatArgs[i]=params[i];
+	                // Build a array for the rest
+	                StringBuilder b = new StringBuilder();
+	                for (;i<paramCount;i++)
+	                {   if (b.length()>0)
+	                        b.append(", ");
+	                    b.append(String.valueOf(params[i]));
+	                }
+	            	formatArgs[patParamCount-1]=b.toString();
                 }
-                formatArgs[patParamCount-1]=b.toString();
             }
             // format now
             String msg = MessageFormat.format(pattern, formatArgs);



Mime
View raw message