Author: kkolinko Date: Mon Apr 8 22:14:13 2013 New Revision: 1465810 URL: http://svn.apache.org/r1465810 Log: Simplify API of ErrorDispatcher class by using varargs. Localizer will now treat zero-length array of arguments in the same way as null.
Modified: tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java?rev=1465810&r1=1465809&r2=1465810&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java Mon Apr 8 22:14:13 2013 @@ -70,133 +70,10 @@ public class ErrorDispatcher { * message. * * @param errCode Error code + * @param args Arguments for parametric replacement */ - public void jspError(String errCode) throws JasperException { - dispatch(null, errCode, null, null); - } - - /* - * Dispatches the given JSP parse error to the configured error handler. - * - * The given error code is localized. If it is not found in the - * resource bundle for localized error messages, it is used as the error - * message. - * - * @param where Error location - * @param errCode Error code - */ - public void jspError(Mark where, String errCode) throws JasperException { - dispatch(where, errCode, null, null); - } - - /* - * Dispatches the given JSP parse error to the configured error handler. - * - * The given error code is localized. If it is not found in the - * resource bundle for localized error messages, it is used as the error - * message. - * - * @param n Node that caused the error - * @param errCode Error code - */ - public void jspError(Node n, String errCode) throws JasperException { - dispatch(n.getStart(), errCode, null, null); - } - - /* - * Dispatches the given JSP parse error to the configured error handler. - * - * The given error code is localized. If it is not found in the - * resource bundle for localized error messages, it is used as the error - * message. - * - * @param errCode Error code - * @param arg Argument for parametric replacement - */ - public void jspError(String errCode, String arg) throws JasperException { - dispatch(null, errCode, new Object[] {arg}, null); - } - - /* - * Dispatches the given JSP parse error to the configured error handler. - * - * The given error code is localized. If it is not found in the - * resource bundle for localized error messages, it is used as the error - * message. - * - * @param where Error location - * @param errCode Error code - * @param arg Argument for parametric replacement - */ - public void jspError(Mark where, String errCode, String arg) - throws JasperException { - dispatch(where, errCode, new Object[] {arg}, null); - } - - /* - * Dispatches the given JSP parse error to the configured error handler. - * - * The given error code is localized. If it is not found in the - * resource bundle for localized error messages, it is used as the error - * message. - * - * @param n Node that caused the error - * @param errCode Error code - * @param arg Argument for parametric replacement - */ - public void jspError(Node n, String errCode, String arg) - throws JasperException { - dispatch(n.getStart(), errCode, new Object[] {arg}, null); - } - - /* - * Dispatches the given JSP parse error to the configured error handler. - * - * The given error code is localized. If it is not found in the - * resource bundle for localized error messages, it is used as the error - * message. - * - * @param errCode Error code - * @param arg1 First argument for parametric replacement - * @param arg2 Second argument for parametric replacement - */ - public void jspError(String errCode, String arg1, String arg2) - throws JasperException { - dispatch(null, errCode, new Object[] {arg1, arg2}, null); - } - - /* - * Dispatches the given JSP parse error to the configured error handler. - * - * The given error code is localized. If it is not found in the - * resource bundle for localized error messages, it is used as the error - * message. - * - * @param errCode Error code - * @param arg1 First argument for parametric replacement - * @param arg2 Second argument for parametric replacement - * @param arg3 Third argument for parametric replacement - */ - public void jspError(String errCode, String arg1, String arg2, String arg3) - throws JasperException { - dispatch(null, errCode, new Object[] {arg1, arg2, arg3}, null); - } - - /* - * Dispatches the given JSP parse error to the configured error handler. - * - * The given error code is localized. If it is not found in the - * resource bundle for localized error messages, it is used as the error - * message. - * - * @param where Error location - * @param errCode Error code - * @param arg1 First argument for parametric replacement - * @param arg2 Second argument for parametric replacement - */ - public void jspError(Mark where, String errCode, String arg1, String arg2) - throws JasperException { - dispatch(where, errCode, new Object[] {arg1, arg2}, null); + public void jspError(String errCode, String... args) throws JasperException { + dispatch(null, errCode, args, null); } /* @@ -208,33 +85,11 @@ public class ErrorDispatcher { * * @param where Error location * @param errCode Error code - * @param arg1 First argument for parametric replacement - * @param arg2 Second argument for parametric replacement - * @param arg3 Third argument for parametric replacement - */ - - public void jspError(Mark where, String errCode, String arg1, String arg2, - String arg3) - throws JasperException { - dispatch(where, errCode, new Object[] {arg1, arg2, arg3}, null); - } - - /* - * Dispatches the given JSP parse error to the configured error handler. - * - * The given error code is localized. If it is not found in the - * resource bundle for localized error messages, it is used as the error - * message. - * - * @param n Node that caused the error - * @param errCode Error code - * @param arg1 First argument for parametric replacement - * @param arg2 Second argument for parametric replacement + * @param args Arguments for parametric replacement */ - - public void jspError(Node n, String errCode, String arg1, String arg2) - throws JasperException { - dispatch(n.getStart(), errCode, new Object[] {arg1, arg2}, null); + public void jspError(Mark where, String errCode, String... args) + throws JasperException { + dispatch(where, errCode, args, null); } /* @@ -246,15 +101,11 @@ public class ErrorDispatcher { * * @param n Node that caused the error * @param errCode Error code - * @param arg1 First argument for parametric replacement - * @param arg2 Second argument for parametric replacement - * @param arg3 Third argument for parametric replacement + * @param args Arguments for parametric replacement */ - - public void jspError(Node n, String errCode, String arg1, String arg2, - String arg3) - throws JasperException { - dispatch(n.getStart(), errCode, new Object[] {arg1, arg2, arg3}, null); + public void jspError(Node n, String errCode, String... args) + throws JasperException { + dispatch(n.getStart(), errCode, args, null); } /* Modified: tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java?rev=1465810&r1=1465809&r2=1465810&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java Mon Apr 8 22:14:13 2013 @@ -151,7 +151,7 @@ public class Localizer { String errMsg = errCode; try { errMsg = bundle.getString(errCode); - if (args != null) { + if (args != null && args.length > 0) { MessageFormat formatter = new MessageFormat(errMsg); errMsg = formatter.format(args); } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1465810&r1=1465809&r2=1465810&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Mon Apr 8 22:14:13 2013 @@ -150,6 +150,14 @@ </scode> </changelog> </subsection> + <subsection name="Jasper"> + <changelog> + <scode> + Simplify API of <code>ErrorDispatcher</code> class by using varargs. + (kkolinko) + </scode> + </changelog> + </subsection> <subsection name="Cluster"> <changelog> <scode> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org