From: <dr...@us...> - 2002-11-11 04:26:15
|
Update of /cvsroot/webmacro/webmacro/src/org/webmacro/directive In directory usw-pr-cvs1:/tmp/cvs-serv9803/src/org/webmacro/directive Modified Files: AlternateDirective.java BeanDirective.java CountDirective.java DefaultDirective.java Directive.java ForeachDirective.java IfDirective.java SetDirective.java SetblockDirective.java Log Message: - Changed Directive.writeWarning() to always include the context.currentLocation() and to always write the warning message to a log named "directive". Adjusted directives that use .writeWarning(). - Added a test case for #count Index: AlternateDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/AlternateDirective.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AlternateDirective.java 11 Jun 2002 17:43:20 -0000 1.9 --- AlternateDirective.java 11 Nov 2002 04:26:12 -0000 1.10 *************** *** 113,117 **** catch (Exception e) { String warning = "#alternate: list argument is not a list: " + l; - context.getLog("engine").warning(warning + "; " + e); writeWarning(warning, context, out); return; --- 113,116 ---- Index: BeanDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/BeanDirective.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** BeanDirective.java 12 Jun 2002 17:17:28 -0000 1.9 --- BeanDirective.java 11 Nov 2002 04:26:12 -0000 1.10 *************** *** 252,256 **** catch (Exception e) { String errorText = "BeanDirective: Unable to load bean " + target + " of type " + _className; - _log.error(errorText, e); writeWarning(errorText, context, out); } --- 252,255 ---- Index: CountDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/CountDirective.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CountDirective.java 25 Oct 2002 01:41:05 -0000 1.2 --- CountDirective.java 11 Nov 2002 04:26:12 -0000 1.3 *************** *** 41,45 **** }; ! private static final DirectiveDescriptor _desc = new DirectiveDescriptor("for", null, _args, null); public static DirectiveDescriptor getDescriptor() { --- 41,45 ---- }; ! private static final DirectiveDescriptor _desc = new DirectiveDescriptor("count", null, _args, null); public static DirectiveDescriptor getDescriptor() { *************** *** 109,114 **** if (tmp != null) start = Integer.parseInt(tmp.toString()); ! else ! throw new PropertyException ("Starting value cannot be null"); } --- 109,116 ---- if (tmp != null) start = Integer.parseInt(tmp.toString()); ! else { ! writeWarning("#count: Starting value cannot be null. Not counting", context, out); ! return; ! } } *************** *** 118,123 **** if (tmp != null) end = Integer.parseInt(tmp.toString()); ! else ! throw new PropertyException ("Ending value cannot be null"); } --- 120,127 ---- if (tmp != null) end = Integer.parseInt(tmp.toString()); ! else { ! writeWarning("#count: Ending value cannot be null. Not counting", context, out); ! return; ! } } *************** *** 127,138 **** if (tmp != null) step = Integer.parseInt(tmp.toString()); ! else ! throw new PropertyException ("Step value cannot be null"); } ! // just do it ! for (; start<=end; start+=step) { ! _iterator.setValue(context, new Integer(start)); ! _body.write(out, context); } } --- 131,152 ---- if (tmp != null) step = Integer.parseInt(tmp.toString()); ! else { ! writeWarning("#count: Starting value cannot be null. Not counting", context, out); ! return; ! } } ! if (step > 0) { ! for (; start<=end; start+=step) { ! _iterator.setValue(context, new Integer(start)); ! _body.write(out, context); ! } ! } else if (step < 0) { ! for (; start>=end; start+=step) { ! _iterator.setValue(context, new Integer(start)); ! _body.write(out, context); ! } ! } else { ! writeWarning("#count: step cannot be 0. Not counting", context, out); } } Index: DefaultDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/DefaultDirective.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DefaultDirective.java 11 Jun 2002 17:43:20 -0000 1.3 --- DefaultDirective.java 11 Nov 2002 04:26:12 -0000 1.4 *************** *** 92,96 **** catch (Exception e) { String errorText = "#default: Unable to set default value for " + target; - context.getBroker().getLog("engine").error(errorText); writeWarning(errorText, context, out); } --- 92,95 ---- Index: Directive.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/Directive.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Directive.java 12 Jun 2002 17:17:28 -0000 1.18 --- Directive.java 11 Nov 2002 04:26:12 -0000 1.19 *************** *** 105,109 **** throws IOException, PropertyException { return context.getEvaluationExceptionHandler() ! .warningString("WARNING: " + warning); } --- 105,109 ---- throws IOException, PropertyException { return context.getEvaluationExceptionHandler() ! .warningString("WARNING: " + warning + " at " + context.getCurrentLocation()); } *************** *** 111,122 **** * Convenience method for directives to write HTML warnings into the output * stream. Eventually this will be parameterizable so that HTML is not ! * assumed to be the only underlying language. */ ! ! protected static void writeWarning(String warning, ! Context context, ! FastWriter writer) ! throws IOException, PropertyException { ! writer.write(getWarningText(warning, context)); } --- 111,122 ---- * Convenience method for directives to write HTML warnings into the output * stream. Eventually this will be parameterizable so that HTML is not ! * assumed to be the only underlying language.<p> ! * ! * This method also outputs the same warning message to a log named "directive" */ ! protected static void writeWarning(String warning, Context context, FastWriter writer) throws IOException, PropertyException { ! warning = getWarningText(warning, context); ! context.getLog("directive").warning(warning); ! writer.write(getWarningText(warning, context)); } Index: ForeachDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/ForeachDirective.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ForeachDirective.java 31 Oct 2002 17:34:03 -0000 1.16 --- ForeachDirective.java 11 Nov 2002 04:26:12 -0000 1.17 *************** *** 113,117 **** else { String warning = "#foreach: Cannot evaluate limit"; - context.getLog("engine").warning(warning); writeWarning(warning, context, out); } --- 113,116 ---- *************** *** 126,130 **** else { String warning = "#foreach: Cannot evaluate loop start"; - context.getLog("engine").warning(warning); writeWarning(warning, context, out); } --- 125,128 ---- *************** *** 141,146 **** warning += list; ! warning += ": " + e.getMessage() + " at " + context.getCurrentLocation(); ! context.getLog("engine").warning(warning); writeWarning(warning, context, out); return; --- 139,143 ---- warning += list; ! warning += ": " + e.getMessage(); writeWarning(warning, context, out); return; *************** *** 156,160 **** catch (PropertyException e) { String errorText = "#foreach: Unable to set list index"; - context.getBroker().getLog("engine").error(errorText); writeWarning(errorText, context, out); } --- 153,156 ---- Index: IfDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/IfDirective.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** IfDirective.java 1 Nov 2002 22:15:31 -0000 1.13 --- IfDirective.java 11 Nov 2002 04:26:12 -0000 1.14 *************** *** 192,197 **** } catch (Exception e) { ! String warning = "#if: Error evaluating condition: " + e + " at " + context.getCurrentLocation(); ! context.getLog("engine").warning(warning); writeWarning(warning, context, out); } --- 192,196 ---- } catch (Exception e) { ! String warning = "#if: Error evaluating condition: " + e; writeWarning(warning, context, out); } Index: SetDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/SetDirective.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SetDirective.java 11 Jun 2002 17:43:20 -0000 1.13 --- SetDirective.java 11 Nov 2002 04:26:12 -0000 1.14 *************** *** 87,91 **** catch (Exception e) { String errorText = "#set: Unable to set value: " + target; - context.getBroker().getLog("engine").error(errorText); writeWarning(errorText, context, out); } --- 87,90 ---- Index: SetblockDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/SetblockDirective.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SetblockDirective.java 5 Sep 2002 05:24:29 -0000 1.3 --- SetblockDirective.java 11 Nov 2002 04:26:12 -0000 1.4 *************** *** 89,93 **** catch (Exception e) { String errorText = "#setblock: Unable to set " + target; - context.getBroker().getLog("engine").error(errorText); writeWarning(errorText, context, out); } --- 89,92 ---- |