--- MessageTag.java Tue Dec 10 14:38:26 2002 +++ MessageTag2.java Tue Dec 10 14:36:29 2002 @@ -188,11 +188,7 @@ public void addArg(Object arg) { _arguments.add(arg); - if (_debug) - { - ServletContext sc = pageContext.getServletContext(); - sc.log("i18n:message added arg: " + arg.toString()); - } + log("added arg: " + arg.toString()); } /** @@ -242,16 +238,11 @@ try { _value = bundle.getString(key); - if (_debug) - { - ServletContext sc = pageContext.getServletContext(); - sc.log("i18n: message: template for " + key + " is: " + _value); - } + log("template for " + key + " is: " + _value); } catch (java.util.MissingResourceException e) { - ServletContext sc = pageContext.getServletContext(); - sc.log("value not found for key:" + key); + log("value not found for key:" + key); } return BodyTag.EVAL_BODY_TAG; @@ -284,12 +275,7 @@ if ( _value == null) { - if (_debug) - { - ServletContext sc = pageContext.getServletContext(); - String key = this.getKey(); - sc.log("i18n: message: skipping null value for " + key); - } + log("skipping null value for " + _key); } else if (id != null) { @@ -310,6 +296,20 @@ // only process the body once return BodyTag.EVAL_PAGE; } - + + /** + * log a message to the servlet context log if we are in + * debug mode (otherwise, do nothing). + * @param message the message to log + */ + private void log(String message) + { + if (_debug) + { + ServletContext sc = pageContext.getServletContext(); + sc.log("i18n:message: " + message); + } + } + } // MessageTag