W3C home > Mailing lists > Public > www-validator-cvs@w3.org > September 2007

2002/css-validator/org/w3c/css/util InvalidParamException.java,1.5,1.6

From: Julien Grand-Mourcel via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 13 Sep 2007 10:21:02 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1IVlok-0007wc-Rd@lionel-hutz.w3.org>

Update of /sources/public/2002/css-validator/org/w3c/css/util
In directory hutz:/tmp/cvs-serv30481/org/w3c/css/util

Modified Files:
	InvalidParamException.java 
Log Message:
Handling list of error messages instead of just one or two messages

Index: InvalidParamException.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/util/InvalidParamException.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- InvalidParamException.java	14 Sep 2005 15:15:32 -0000	1.5
+++ InvalidParamException.java	13 Sep 2007 10:21:00 -0000	1.6
@@ -37,8 +37,7 @@
      * @param message a message to add
      */
     public InvalidParamException(String error, Object message, ApplContext ac) {
-	super(processError(error,
-			   (message != null)?message.toString():null, "", ac));
+    	super(processError(error, (message != null)?message:null, ac));
     }
 
     /**
@@ -55,6 +54,30 @@
 			   (message2 != null)?message2.toString():null,
 			   ac));
     }
+    
+    private static String processError(String error, Object args, ApplContext ac) {
+    	if (args instanceof String[]) {
+			String str = null;
+			
+			if (error != null) {
+			str = ac.getMsg().getErrorString(error);
+			}
+			if (str == null)
+				return "can't find the error message for " + error;
+			else {
+			// replace all parameters
+				int j = 0;
+				for (int i = 0; (i = str.indexOf("%s")) >= 0 && j < ((String[]) args).length; ) {
+					str = str.substring(0, i) + ((String[]) args)[j++] + str.substring(i+2);
+				}
+				return str;
+			}
+    	} else {
+    		return processError(error, args.toString(), "", ac);
+    	}
+    }
+    
+    
 
     private static String processError(String error, String arg1,
 				       String arg2, ApplContext ac) {
Received on Thursday, 13 September 2007 10:21:07 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 10 December 2014 20:08:28 UTC