Update of /cvsroot/webmacro/webmacro/src/org/webmacro/directive In directory sc8-pr-cvs1:/tmp/cvs-serv6675/src/org/webmacro/directive Modified Files: AlternateDirective.java ArgsHolder.java AttributeDirective.java BeanDirective.java CommentDirective.java CountDirective.java DefaultDirective.java Directive.java DirectiveArgs.java DirectiveBuilder.java DirectiveDescriptor.java DirectiveProvider.java DummyDirective.java EncodeDirective.java EscapeDirective.java ForeachDirective.java GlobalDirective.java IfDirective.java IncludeDirective.java MacroDirective.java ParamDirective.java ProfileDirective.java PropertyDirective.java SetDirective.java SetblockDirective.java SilenceDirective.java TextDirective.java TypeDirective.java Log Message: If this doesn't drive our SF "activity" stats through the roof, I don't know what will. Mass re-formatting of all code, following (to the best of my interpertation) the Sun (w/ jakarta tweaks) coding style guidelines defined here: http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html and here: http://jakarta.apache.org/turbine/common/code-standards.html I did this reformatting with IDEA 3.0.5, and I am going to commit the style configuration for IDEA (if I can find it). Index: AlternateDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/AlternateDirective.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AlternateDirective.java 11 Nov 2002 19:22:36 -0000 1.11 --- AlternateDirective.java 12 Jun 2003 00:47:44 -0000 1.12 *************** *** 19,34 **** * * See www.webmacro.org for more information on the WebMacro project. ! */ ! ! package org.webmacro.directive; ! ! import java.io.*; ! import java.util.*; ! ! import org.webmacro.*; ! import org.webmacro.engine.BuildContext; ! import org.webmacro.engine.BuildException; ! import org.webmacro.engine.Variable; ! /** * <b>#alternate</b><p> --- 19,36 ---- * * See www.webmacro.org for more information on the WebMacro project. ! */ ! ! package org.webmacro.directive; ! ! import org.webmacro.*; ! import org.webmacro.engine.BuildContext; ! import org.webmacro.engine.BuildException; ! import org.webmacro.engine.Variable; ! ! import java.io.IOException; ! import java.util.ArrayList; ! import java.util.Iterator; ! import java.util.List; ! /** * <b>#alternate</b><p> *************** *** 60,165 **** * is evaluated, it will have the value "blue", and so on through the list. When it gets * to the end of the list, it wraps back around to the beginning. ! */ ! public class AlternateDirective extends Directive { ! ! private static final int ALTERNATE_TARGET = 1; ! private static final int ALTERNATE_THROUGH = 2; ! private static final int ALTERNATE_LIST = 3; ! ! private Variable target; ! private Object list; ! ! private static final ArgDescriptor[] ! myArgs = new ArgDescriptor[]{ ! new LValueArg(ALTERNATE_TARGET), ! new KeywordArg(ALTERNATE_THROUGH, "through"), ! new RValueArg(ALTERNATE_LIST) ! }; ! ! private static final DirectiveDescriptor ! myDescr = new DirectiveDescriptor("alternate", null, myArgs, null); ! ! public static DirectiveDescriptor getDescriptor() { ! return myDescr; ! } ! ! public Object build(DirectiveBuilder builder, ! BuildContext bc) ! throws BuildException { ! try { ! target = (Variable) builder.getArg(ALTERNATE_TARGET, bc); ! } ! catch (ClassCastException e) { ! throw new NotVariableBuildException(myDescr.name, e); ! } ! list = builder.getArg(ALTERNATE_LIST, bc); ! return this; ! } ! ! public void write(FastWriter out, Context context) ! throws PropertyException, IOException { ! Object l = null; ! ! try { ! if (list instanceof Macro) ! l = ((Macro) list).evaluate(context); ! else ! l = list; ! ! Iterator itr = context.getBroker()._propertyOperators.getIterator(l); ! ! target.setValue(context, new IteratorAlternator(itr)); ! } ! catch (Exception e) { ! String warning = "#alternate: list argument is not a list: " + l; ! writeWarning(warning, context, out); ! return; ! } ! } ! ! public void accept(TemplateVisitor v) { ! v.beginDirective(myDescr.name); ! v.visitDirectiveArg("AlternateTarget", target); ! v.visitDirectiveArg("AlternateList", list); ! v.endDirective(); ! } ! ! } ! ! abstract class Alternator implements Macro { ! ! public abstract Object evaluate(Context context); ! ! public void write(FastWriter out, Context context) throws PropertyException, IOException { ! Object o = evaluate(context); ! if (o != null) ! out.write(o.toString()); ! } ! } ! ! class IteratorAlternator extends Alternator { ! ! private Iterator itr; ! private List list; ! private int index = -1; ! ! public IteratorAlternator(Iterator itr) { ! this.itr = itr; ! this.list = new ArrayList(); ! } ! ! public Object evaluate(Context context) { ! Object o; ! if (index == -1 && itr.hasNext()) { ! o = itr.next(); ! list.add(o); ! } ! else { ! index++; ! if (index == list.size()) ! index = 0; ! o = list.get(index); ! } ! return o; ! } } --- 62,183 ---- * is evaluated, it will have the value "blue", and so on through the list. When it gets * to the end of the list, it wraps back around to the beginning. ! */ ! public class AlternateDirective extends Directive ! { ! ! private static final int ALTERNATE_TARGET = 1; ! private static final int ALTERNATE_THROUGH = 2; ! private static final int ALTERNATE_LIST = 3; ! ! private Variable target; ! private Object list; ! ! private static final ArgDescriptor[] ! myArgs = new ArgDescriptor[]{ ! new LValueArg(ALTERNATE_TARGET), ! new KeywordArg(ALTERNATE_THROUGH, "through"), ! new RValueArg(ALTERNATE_LIST) ! }; ! ! private static final DirectiveDescriptor ! myDescr = new DirectiveDescriptor("alternate", null, myArgs, null); ! ! public static DirectiveDescriptor getDescriptor () ! { ! return myDescr; ! } ! ! public Object build (DirectiveBuilder builder, ! BuildContext bc) ! throws BuildException ! { ! try ! { ! target = (Variable) builder.getArg(ALTERNATE_TARGET, bc); ! } ! catch (ClassCastException e) ! { ! throw new NotVariableBuildException(myDescr.name, e); ! } ! list = builder.getArg(ALTERNATE_LIST, bc); ! return this; ! } ! ! public void write (FastWriter out, Context context) ! throws PropertyException, IOException ! { ! Object l = null; ! ! try ! { ! if (list instanceof Macro) ! l = ((Macro) list).evaluate(context); ! else ! l = list; ! ! Iterator itr = context.getBroker()._propertyOperators.getIterator(l); ! ! target.setValue(context, new IteratorAlternator(itr)); ! } ! catch (Exception e) ! { ! String warning = "#alternate: list argument is not a list: " + l; ! writeWarning(warning, context, out); ! return; ! } ! } ! ! public void accept (TemplateVisitor v) ! { ! v.beginDirective(myDescr.name); ! v.visitDirectiveArg("AlternateTarget", target); ! v.visitDirectiveArg("AlternateList", list); ! v.endDirective(); ! } ! ! } ! ! abstract class Alternator implements Macro ! { ! ! public abstract Object evaluate (Context context); ! ! public void write (FastWriter out, Context context) throws PropertyException, IOException ! { ! Object o = evaluate(context); ! if (o != null) ! out.write(o.toString()); ! } ! } ! ! class IteratorAlternator extends Alternator ! { ! ! private Iterator itr; ! private List list; ! private int index = -1; ! ! public IteratorAlternator (Iterator itr) ! { ! this.itr = itr; ! this.list = new ArrayList(); ! } ! ! public Object evaluate (Context context) ! { ! Object o; ! if (index == -1 && itr.hasNext()) ! { ! o = itr.next(); ! list.add(o); ! } ! else ! { ! index++; ! if (index == list.size()) ! index = 0; ! o = list.get(index); ! } ! return o; ! } } Index: ArgsHolder.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/ArgsHolder.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ArgsHolder.java 11 Jun 2002 17:43:20 -0000 1.7 --- ArgsHolder.java 12 Jun 2003 00:47:44 -0000 1.8 *************** *** 35,112 **** */ ! public final class ArgsHolder implements DirectiveArgs { ! // The argument descriptors for the arguments we hold ! private Directive.ArgDescriptor[] args; ! // The parser will call setArg(), and we'll store them here. For ! // each argument in the argument list, the corresponding argument data ! // will be in the same index into buildArgs. ! private Object[] buildArgs; ! public ArgsHolder(Directive.ArgDescriptor[] args) { ! this.args = args; ! buildArgs = new Object[args.length]; ! } ! private final int findArgIndex(int id) ! throws BuildException { ! for (int i = 0; i < args.length; i++) { ! if (args[i].id == id) ! return i; ! } ! throw new BuildException("Invalid argument ID " + id + " requested "); ! } ! /** ! * Get the argument at the specified <code>index</code>. This is different than getting ! * an argument by it's <code>id</code> ! */ ! public Object getExactArg(int idx) throws BuildException { ! return buildArgs[idx]; ! } ! /** ! * How many arguments does this ArgsHolder have? ! */ ! public final int getArgCount() { ! return buildArgs.length; ! } ! /** ! * Retrieve the argument whose id is the specified id. ! */ ! public final Object getArg(int id) ! throws BuildException { ! int index = findArgIndex(id); ! return buildArgs[index]; ! } ! /** ! * Retrieve the argument whose id is the specified id, and if it is a ! * Builder, build it with the specified build context. ! */ ! public final Object getArg(int id, BuildContext bc) ! throws BuildException { ! int index = findArgIndex(id); ! Object o = buildArgs[index]; ! return (o instanceof Builder) ! ? ((Builder) o).build(bc) ! : o; ! } ! /** ! * Set the argument whose id is the specified id. If the argument has ! * already been set, it is overwritten. Generally not used by directives, ! * only used by the parser. ! */ ! public final void setArg(int id, Object o) ! throws BuildException { ! int index = findArgIndex(id); ! buildArgs[index] = o; ! } } --- 35,121 ---- */ ! public final class ArgsHolder implements DirectiveArgs ! { ! // The argument descriptors for the arguments we hold ! private Directive.ArgDescriptor[] args; ! // The parser will call setArg(), and we'll store them here. For ! // each argument in the argument list, the corresponding argument data ! // will be in the same index into buildArgs. ! private Object[] buildArgs; ! public ArgsHolder (Directive.ArgDescriptor[] args) ! { ! this.args = args; ! buildArgs = new Object[args.length]; ! } ! private final int findArgIndex (int id) ! throws BuildException ! { ! for (int i = 0; i < args.length; i++) ! { ! if (args[i].id == id) ! return i; ! } ! throw new BuildException("Invalid argument ID " + id + " requested "); ! } ! /** ! * Get the argument at the specified <code>index</code>. This is different than getting ! * an argument by it's <code>id</code> ! */ ! public Object getExactArg (int idx) throws BuildException ! { ! return buildArgs[idx]; ! } ! /** ! * How many arguments does this ArgsHolder have? ! */ ! public final int getArgCount () ! { ! return buildArgs.length; ! } ! /** ! * Retrieve the argument whose id is the specified id. ! */ ! public final Object getArg (int id) ! throws BuildException ! { ! int index = findArgIndex(id); ! return buildArgs[index]; ! } ! /** ! * Retrieve the argument whose id is the specified id, and if it is a ! * Builder, build it with the specified build context. ! */ ! public final Object getArg (int id, BuildContext bc) ! throws BuildException ! { ! int index = findArgIndex(id); ! Object o = buildArgs[index]; ! return (o instanceof Builder) ! ? ((Builder) o).build(bc) ! : o; ! } ! /** ! * Set the argument whose id is the specified id. If the argument has ! * already been set, it is overwritten. Generally not used by directives, ! * only used by the parser. ! */ ! public final void setArg (int id, Object o) ! throws BuildException ! { ! int index = findArgIndex(id); ! buildArgs[index] = o; ! } } Index: AttributeDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/AttributeDirective.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AttributeDirective.java 11 Jun 2002 17:43:20 -0000 1.7 --- AttributeDirective.java 12 Jun 2003 00:47:44 -0000 1.8 *************** *** 23,28 **** package org.webmacro.directive; - import java.io.*; - import org.webmacro.Context; import org.webmacro.FastWriter; --- 23,26 ---- *************** *** 32,35 **** --- 30,35 ---- import org.webmacro.engine.Variable; + import java.io.IOException; + /** * The #attribute directive allows you to set a template attribute such *************** *** 37,84 **** */ ! public class AttributeDirective extends Directive { ! private static final int ATTRIBUTE_TARGET = 1; ! private static final int ATTRIBUTE_RESULT = 2; ! private static final ArgDescriptor[] ! myArgs = new ArgDescriptor[]{ ! new LValueArg(ATTRIBUTE_TARGET), ! new AssignmentArg(), ! new RValueArg(ATTRIBUTE_RESULT) ! }; ! private static final DirectiveDescriptor ! myDescr = new DirectiveDescriptor(null, null, myArgs, null); ! public static DirectiveDescriptor getDescriptor() { ! return myDescr; ! } ! public Object build(DirectiveBuilder builder, ! BuildContext bc) ! throws BuildException { ! Variable target = null; ! try { ! target = (Variable) builder.getArg(ATTRIBUTE_TARGET, bc); ! Object result = builder.getArg(ATTRIBUTE_RESULT, bc); ! if (!target.isSimpleName()) ! throw new NotSimpleVariableBuildException(myDescr.name); ! target.setValue(bc, result); ! } ! catch (ClassCastException e) { ! throw new NotVariableBuildException(myDescr.name, e); ! } ! catch (PropertyException e) { ! throw new BuildException("#attribute: Exception setting variable " ! + target.toString(), e); ! } ! return null; ! } ! public void write(FastWriter out, Context context) ! throws PropertyException, IOException { ! } } --- 37,91 ---- */ ! public class AttributeDirective extends Directive ! { ! private static final int ATTRIBUTE_TARGET = 1; ! private static final int ATTRIBUTE_RESULT = 2; ! private static final ArgDescriptor[] ! myArgs = new ArgDescriptor[]{ ! new LValueArg(ATTRIBUTE_TARGET), ! new AssignmentArg(), ! new RValueArg(ATTRIBUTE_RESULT) ! }; ! private static final DirectiveDescriptor ! myDescr = new DirectiveDescriptor(null, null, myArgs, null); ! public static DirectiveDescriptor getDescriptor () ! { ! return myDescr; ! } ! public Object build (DirectiveBuilder builder, ! BuildContext bc) ! throws BuildException ! { ! Variable target = null; ! try ! { ! target = (Variable) builder.getArg(ATTRIBUTE_TARGET, bc); ! Object result = builder.getArg(ATTRIBUTE_RESULT, bc); ! if (!target.isSimpleName()) ! throw new NotSimpleVariableBuildException(myDescr.name); ! target.setValue(bc, result); ! } ! catch (ClassCastException e) ! { ! throw new NotVariableBuildException(myDescr.name, e); ! } ! catch (PropertyException e) ! { ! throw new BuildException("#attribute: Exception setting variable " ! + target.toString(), e); ! } ! return null; ! } ! public void write (FastWriter out, Context context) ! throws PropertyException, IOException ! { ! } } Index: BeanDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/BeanDirective.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** BeanDirective.java 20 Dec 2002 02:25:24 -0000 1.11 --- BeanDirective.java 12 Jun 2003 00:47:44 -0000 1.12 *************** *** 28,396 **** */ - import java.io.*; - import java.util.*; - import org.webmacro.*; import org.webmacro.engine.*; ! public class BeanDirective extends Directive { ! private static final int BEAN_TARGET = 1; ! private static final int BEAN_CLASS_NAME = 2; ! private static final int BEAN_SCOPE = 3; ! private static final int BEAN_SCOPE_GLOBAL = 4; ! private static final int BEAN_SCOPE_APPLICATION = 5; ! private static final int BEAN_SCOPE_SESSION = 6; ! private static final int BEAN_SCOPE_PAGE = 7; ! private static final int BEAN_INITARGS = 8; ! private static final int BEAN_INITARGS_VAL = 9; ! private static final int BEAN_TYPE_STATIC = 10; ! private static final int BEAN_ON_NEW = 11; ! private static final int BEAN_ON_NEW_BLOCK = 12; ! private static final UndefinedMacro UNDEF = UndefinedMacro.getInstance(); ! private static int[] BEAN_SCOPES = { ! BEAN_SCOPE_GLOBAL, BEAN_SCOPE_APPLICATION, ! BEAN_SCOPE_SESSION, BEAN_SCOPE_PAGE ! }; ! private Variable target; ! private String targetName; ! private String _className; ! private int scope; ! private boolean isStaticClass; ! private Object initArgObj; ! private Object[] initArgs; ! private Block onNewBlock; ! private Log _log; ! private List _impliedPackages; ! private List _allowedPackages; ! private Class _class; ! private BeanConf beanConf; ! private Broker _broker; ! private static final ArgDescriptor[] ! myArgs = new ArgDescriptor[]{ ! new LValueArg(BEAN_TARGET), ! new AssignmentArg(), ! new QuotedStringArg(BEAN_CLASS_NAME), ! new OptionalGroup(3), ! new KeywordArg(BEAN_SCOPE, "scope"), ! new AssignmentArg(), ! new SingleOptionChoice(5), ! new OptionalGroup(1), ! new KeywordArg(BEAN_SCOPE_GLOBAL, "global"), ! new OptionalGroup(1), ! new KeywordArg(BEAN_SCOPE_APPLICATION, "application"), ! new OptionalGroup(1), ! new KeywordArg(BEAN_SCOPE_SESSION, "session"), ! new OptionalGroup(1), ! new KeywordArg(BEAN_SCOPE_PAGE, "page"), ! new OptionalGroup(1), ! new KeywordArg(BEAN_TYPE_STATIC, "static"), ! new OptionalGroup(2), ! new KeywordArg(BEAN_INITARGS, "initArgs"), ! new RValueArg(BEAN_INITARGS_VAL), ! new OptionalGroup(2), ! new KeywordArg(BEAN_ON_NEW, "onNew"), ! new BlockArg(BEAN_ON_NEW_BLOCK) ! }; ! private static final DirectiveDescriptor ! myDescr = new DirectiveDescriptor("bean", null, myArgs, null); ! public static DirectiveDescriptor getDescriptor() { ! return myDescr; ! } ! public BeanDirective() { ! } ! public Object build(DirectiveBuilder builder, BuildContext bc) ! throws BuildException { ! _broker = bc.getBroker(); ! _log = _broker.getLog("directive"); ! // BeanConf object is created by the init method when this directive ! // is registered by the DirectiveProvider ! beanConf = (BeanConf) _broker.getBrokerLocal("BeanDirective.Conf"); ! if (beanConf == null) { ! throw new BuildException( ! "Error building the #bean directive. The directive has not been properly initialized!"); ! } ! try { ! target = (Variable) builder.getArg(BEAN_TARGET, bc); ! } ! catch (ClassCastException e) { ! throw new NotVariableBuildException(myDescr.name, e); ! } ! targetName = target.getName(); ! _className = (String) builder.getArg(BEAN_CLASS_NAME, bc); ! _class = classForName(_className); ! // check if bean is declared as static ! // this implies global scope and no constructor invocation ! isStaticClass = (builder.getArg(BEAN_TYPE_STATIC) != null); ! if (isStaticClass) ! scope = BEAN_SCOPE_GLOBAL; ! else { ! scope = getScope(builder, bc); ! // initArgs is only valid for non-static beans ! initArgObj = builder.getArg(BEAN_INITARGS_VAL); ! if (initArgObj instanceof Builder) ! initArgObj = ((Builder) initArgObj).build(bc); ! } ! onNewBlock = (Block) builder.getArg(BEAN_ON_NEW_BLOCK, bc); ! _log.debug("BeanDirective, target=" + target ! + ", className=" + _className + ", scope=" + scope ! + ", isStaticClass=" + isStaticClass + ", initArgs=" + initArgObj); ! return this; ! } ! public void write(FastWriter out, Context context) ! throws PropertyException, IOException { ! Map globalBeans = BeanConf.globalBeans; ! Map appBeans = beanConf.appBeans; ! boolean isNew = false; ! try { ! while (initArgObj instanceof Macro && initArgObj != UNDEF) ! initArgObj = ((Macro) initArgObj).evaluate(context); ! // store init args in array ! if (initArgObj == null || initArgObj.getClass().isArray()) { ! initArgs = (Object[]) initArgObj; ! } ! else { ! initArgs = new Object[] { initArgObj }; ! } ! Object o = null; ! Class c = null; ! switch (scope) { ! case BEAN_SCOPE_GLOBAL: ! synchronized (globalBeans) { ! o = globalBeans.get(targetName); ! if (o == null) { ! if (isStaticClass) { ! c = context.getBroker().classForName(_className); ! o = new org.webmacro.engine.StaticClassWrapper(c); ! } ! else { ! //c = Class.forName(_className); ! //o = c.newInstance(); ! o = instantiate(_className, initArgs); ! } ! isNew = true; ! globalBeans.put(targetName, o); ! } ! } ! break; ! case BEAN_SCOPE_APPLICATION: ! synchronized (appBeans) { ! o = appBeans.get(targetName); ! if (o == null) { ! o = instantiate(_className, initArgs); ! isNew = true; ! appBeans.put(targetName, o); ! } ! } ! break; ! case BEAN_SCOPE_SESSION: ! javax.servlet.http.HttpSession session = ! (javax.servlet.http.HttpSession) context.getProperty("Session"); ! //if (context instanceof WebContext){ ! if (session != null) { ! synchronized (session) { ! o = session.getAttribute(targetName); ! if (o == null) { ! o = instantiate(_className, initArgs); ! isNew = true; ! session.setAttribute(targetName, o); ! } ! } ! } ! else { ! PropertyException e = new PropertyException( ! "#bean usage error: session scope is only valid with servlets!"); ! _broker.getEvaluationExceptionHandler().evaluate( ! target, context, e); ! } ! break; ! default: ! // make "page" the default scope ! //case BEAN_SCOPE_PAGE: ! // NOTE: page beans always overwrite anything in the context ! // with the same name ! o = instantiate(_className, initArgs); ! isNew = true; ! if (o != null) { ! Class[] paramTypes = {Context.class}; ! try { ! java.lang.reflect.Method m = o.getClass().getMethod("init", paramTypes); ! if (m != null) { ! Object[] args = {context}; ! m.invoke(o, args); ! } ! } ! catch (Exception e) { // ignore ! } ! } ! break; ! } ! _log.debug("BeanDirective: Class " + _className + " loaded."); ! target.setValue(context, o); ! } ! catch (PropertyException e) { ! this._broker.getEvaluationExceptionHandler().evaluate(target, context, e); ! } ! catch (Exception e) { ! String errorText = "BeanDirective: Unable to load bean " + target + " of type " + _className; ! writeWarning(errorText, context, out); ! } ! if (isNew && onNewBlock != null) ! onNewBlock.write(out, context); ! } ! public void accept(TemplateVisitor v) { ! v.beginDirective(myDescr.name); ! v.visitDirectiveArg("BeanTarget", target); ! v.visitDirectiveArg("BeanClass", _className); ! v.visitDirectiveArg("BeanScope", new Integer(scope)); ! v.visitDirectiveArg("BeanIsStatic", new Boolean(isStaticClass)); ! v.visitDirectiveArg("BeanInitArgs", initArgs); ! v.endDirective(); ! } ! private Object instantiate(String className, Object[] args) ! throws Exception { ! Class c = classForName(className); ! return instantiate(c, args); ! } ! private Object instantiate(Class c, Object[] args) ! throws Exception { ! // @@@ FIXME(BG): either use lastException or don't record it ! Object o = null; ! if (args == null) { ! o = c.newInstance(); ! } ! else { ! Exception lastException = null; ! java.lang.reflect.Constructor[] cons = c.getConstructors(); ! for (int i = 0; i < cons.length; i++) { ! if (cons[i].getParameterTypes().length == args.length) { ! // try to instantiate using this constructor ! try { ! o = cons[i].newInstance(args); ! break; // if successful, we're done! ! } ! catch (Exception e) { ! lastException = e; ! } } ! } ! if (o == null) { ! throw new InstantiationException( ! "Unable to construct object of type " + c.getName() ! + " using the supplied arguments: " ! + java.util.Arrays.asList(args).toString()); ! } ! } ! return o; ! } ! private static int getScope(DirectiveBuilder builder, BuildContext bc) throws org.webmacro.engine.BuildException { ! int scope = -1; ! for (int i = 0; i < BEAN_SCOPES.length; i++) { ! scope = BEAN_SCOPES[i]; ! if (builder.getArg(scope) != null) break; ! } ! return scope; ! } ! public static void init(Broker b) { ! // get configuration parameters ! synchronized (b) { ! BeanConf bCfg = new BeanConf(b); ! b.setBrokerLocal("BeanDirective.Conf", bCfg); ! Log log = b.getLog("directive"); ! log.debug("BeanDirective initialization - impliedPackages: " + bCfg.impliedPackages); ! log.debug("BeanDirective initialization - allowedPackages: " + bCfg.allowedPackages); ! } ! } ! private Class classForName(String className) throws BuildException { ! Class c = null; ! Exception except = null; ! try { ! c = _broker.classForName(className); ! } ! catch (Exception cnfe) { ! except = cnfe; ! // try with implied packages prepended ! for (int i = 0; i < beanConf.impliedPackages.size(); i++) { ! String s = (String) beanConf.impliedPackages.get(i); ! try { ! c = _broker.classForName(s + "." + className); ! break; } ! catch (Exception cnfe2) { ! except = cnfe2; } ! } ! if (c == null) { ! throw new BuildException("Unable to load class " + className, except); ! } ! } ! if (!beanConf.allowedPackages.isEmpty()) { ! // check if class is in a permitted package ! String pkg = c.getPackage().getName(); ! if (!beanConf.allowedPackages.contains(pkg)) { ! throw new BuildException( ! "You are not permitted to load classes from this package (" + pkg ! + "). Check the \"BeanDirective.AllowedPackages\" parameter in the WebMacro.properties file."); ! } ! } ! return c; ! } } ! class BeanConf { ! static Map globalBeans = new HashMap(20); ! Map appBeans = new HashMap(20); ! List impliedPackages; ! List allowedPackages; ! public BeanConf(Broker b) { ! String s = b.getSetting("BeanDirective.ImpliedPackages"); ! impliedPackages = Arrays.asList(org.webmacro.servlet.TextTool.split(s, ",")); ! s = b.getSetting("BeanDirective.AllowedPackages"); ! allowedPackages = Arrays.asList(org.webmacro.servlet.TextTool.split(s, ",")); ! } ! public Map getGlobalBeans() { ! return globalBeans; ! } ! public Map getAppBeans() { ! return appBeans; ! } ! public List getImpliedPackages() { ! return impliedPackages; ! } ! public List getAllowedPackages() { ! return allowedPackages; ! } } --- 28,457 ---- */ import org.webmacro.*; import org.webmacro.engine.*; ! import java.io.IOException; ! import java.util.Arrays; ! import java.util.HashMap; ! import java.util.List; ! import java.util.Map; ! public class BeanDirective extends Directive ! { ! private static final int BEAN_TARGET = 1; ! private static final int BEAN_CLASS_NAME = 2; ! private static final int BEAN_SCOPE = 3; ! private static final int BEAN_SCOPE_GLOBAL = 4; ! private static final int BEAN_SCOPE_APPLICATION = 5; ! private static final int BEAN_SCOPE_SESSION = 6; ! private static final int BEAN_SCOPE_PAGE = 7; ! private static final int BEAN_INITARGS = 8; ! private static final int BEAN_INITARGS_VAL = 9; ! private static final int BEAN_TYPE_STATIC = 10; ! private static final int BEAN_ON_NEW = 11; ! private static final int BEAN_ON_NEW_BLOCK = 12; ! private static final UndefinedMacro UNDEF = UndefinedMacro.getInstance(); ! private static int[] BEAN_SCOPES = { ! BEAN_SCOPE_GLOBAL, BEAN_SCOPE_APPLICATION, ! BEAN_SCOPE_SESSION, BEAN_SCOPE_PAGE ! }; ! private Variable target; ! private String targetName; ! private String _className; ! private int scope; ! private boolean isStaticClass; ! private Object initArgObj; ! private Object[] initArgs; ! private Block onNewBlock; ! private Log _log; ! private List _impliedPackages; ! private List _allowedPackages; ! private Class _class; ! private BeanConf beanConf; ! private Broker _broker; ! private static final ArgDescriptor[] ! myArgs = new ArgDescriptor[]{ ! new LValueArg(BEAN_TARGET), ! new AssignmentArg(), ! new QuotedStringArg(BEAN_CLASS_NAME), ! new OptionalGroup(3), ! new KeywordArg(BEAN_SCOPE, "scope"), ! new AssignmentArg(), ! new SingleOptionChoice(5), ! new OptionalGroup(1), ! new KeywordArg(BEAN_SCOPE_GLOBAL, "global"), ! new OptionalGroup(1), ! new KeywordArg(BEAN_SCOPE_APPLICATION, "application"), ! new OptionalGroup(1), ! new KeywordArg(BEAN_SCOPE_SESSION, "session"), ! new OptionalGroup(1), ! new KeywordArg(BEAN_SCOPE_PAGE, "page"), ! new OptionalGroup(1), ! new KeywordArg(BEAN_TYPE_STATIC, "static"), ! new OptionalGroup(2), ! new KeywordArg(BEAN_INITARGS, "initArgs"), ! new RValueArg(BEAN_INITARGS_VAL), ! new OptionalGroup(2), ! new KeywordArg(BEAN_ON_NEW, "onNew"), ! new BlockArg(BEAN_ON_NEW_BLOCK) ! }; ! private static final DirectiveDescriptor ! myDescr = new DirectiveDescriptor("bean", null, myArgs, null); ! public static DirectiveDescriptor getDescriptor () ! { ! return myDescr; ! } ! public BeanDirective () ! { ! } ! public Object build (DirectiveBuilder builder, BuildContext bc) ! throws BuildException ! { ! _broker = bc.getBroker(); ! _log = _broker.getLog("directive"); ! // BeanConf object is created by the init method when this directive ! // is registered by the DirectiveProvider ! beanConf = (BeanConf) _broker.getBrokerLocal("BeanDirective.Conf"); ! if (beanConf == null) ! { ! throw new BuildException( ! "Error building the #bean directive. The directive has not been properly initialized!"); ! } ! try ! { ! target = (Variable) builder.getArg(BEAN_TARGET, bc); ! } ! catch (ClassCastException e) ! { ! throw new NotVariableBuildException(myDescr.name, e); ! } ! targetName = target.getName(); ! _className = (String) builder.getArg(BEAN_CLASS_NAME, bc); ! _class = classForName(_className); ! // check if bean is declared as static ! // this implies global scope and no constructor invocation ! isStaticClass = (builder.getArg(BEAN_TYPE_STATIC) != null); ! if (isStaticClass) ! scope = BEAN_SCOPE_GLOBAL; ! else ! { ! scope = getScope(builder, bc); ! // initArgs is only valid for non-static beans ! initArgObj = builder.getArg(BEAN_INITARGS_VAL); ! if (initArgObj instanceof Builder) ! initArgObj = ((Builder) initArgObj).build(bc); ! } ! onNewBlock = (Block) builder.getArg(BEAN_ON_NEW_BLOCK, bc); ! _log.debug("BeanDirective, target=" + target ! + ", className=" + _className + ", scope=" + scope ! + ", isStaticClass=" + isStaticClass + ", initArgs=" + initArgObj); ! return this; ! } ! public void write (FastWriter out, Context context) ! throws PropertyException, IOException ! { ! Map globalBeans = BeanConf.globalBeans; ! Map appBeans = beanConf.appBeans; ! boolean isNew = false; ! try ! { ! while (initArgObj instanceof Macro && initArgObj != UNDEF) ! initArgObj = ((Macro) initArgObj).evaluate(context); ! // store init args in array ! if (initArgObj == null || initArgObj.getClass().isArray()) ! { ! initArgs = (Object[]) initArgObj; ! } ! else ! { ! initArgs = new Object[]{initArgObj}; ! } ! Object o = null; ! Class c = null; ! switch (scope) ! { ! case BEAN_SCOPE_GLOBAL: ! synchronized (globalBeans) ! { ! o = globalBeans.get(targetName); ! if (o == null) ! { ! if (isStaticClass) ! { ! c = context.getBroker().classForName(_className); ! o = new org.webmacro.engine.StaticClassWrapper(c); ! } ! else ! { ! //c = Class.forName(_className); ! //o = c.newInstance(); ! o = instantiate(_className, initArgs); ! } ! isNew = true; ! globalBeans.put(targetName, o); ! } ! } ! break; ! case BEAN_SCOPE_APPLICATION: ! synchronized (appBeans) ! { ! o = appBeans.get(targetName); ! if (o == null) ! { ! o = instantiate(_className, initArgs); ! isNew = true; ! appBeans.put(targetName, o); ! } ! } ! break; ! case BEAN_SCOPE_SESSION: ! javax.servlet.http.HttpSession session = ! (javax.servlet.http.HttpSession) context.getProperty("Session"); ! //if (context instanceof WebContext){ ! if (session != null) ! { ! synchronized (session) ! { ! o = session.getAttribute(targetName); ! if (o == null) ! { ! o = instantiate(_className, initArgs); ! isNew = true; ! session.setAttribute(targetName, o); ! } ! } ! } ! else ! { ! PropertyException e = new PropertyException( ! "#bean usage error: session scope is only valid with servlets!"); ! _broker.getEvaluationExceptionHandler().evaluate( ! target, context, e); ! } ! break; ! default: ! // make "page" the default scope ! //case BEAN_SCOPE_PAGE: ! // NOTE: page beans always overwrite anything in the context ! // with the same name ! o = instantiate(_className, initArgs); ! isNew = true; ! if (o != null) ! { ! Class[] paramTypes = {Context.class}; ! try ! { ! java.lang.reflect.Method m = o.getClass().getMethod("init", paramTypes); ! if (m != null) ! { ! Object[] args = {context}; ! m.invoke(o, args); ! } ! } ! catch (Exception e) ! { // ignore ! } ! } ! break; ! } ! _log.debug("BeanDirective: Class " + _className + " loaded."); ! target.setValue(context, o); ! } ! catch (PropertyException e) ! { ! this._broker.getEvaluationExceptionHandler().evaluate(target, context, e); ! } ! catch (Exception e) ! { ! String errorText = "BeanDirective: Unable to load bean " + target + " of type " + _className; ! writeWarning(errorText, context, out); ! } ! if (isNew && onNewBlock != null) ! onNewBlock.write(out, context); ! } ! public void accept (TemplateVisitor v) ! { ! v.beginDirective(myDescr.name); ! v.visitDirectiveArg("BeanTarget", target); ! v.visitDirectiveArg("BeanClass", _className); ! v.visitDirectiveArg("BeanScope", new Integer(scope)); ! v.visitDirectiveArg("BeanIsStatic", new Boolean(isStaticClass)); ! v.visitDirectiveArg("BeanInitArgs", initArgs); ! v.endDirective(); ! } ! private Object instantiate (String className, Object[] args) ! throws Exception ! { ! Class c = classForName(className); ! return instantiate(c, args); ! } ! ! private Object instantiate (Class c, Object[] args) ! throws Exception ! { ! // @@@ FIXME(BG): either use lastException or don't record it ! Object o = null; ! if (args == null) ! { ! o = c.newInstance(); ! } ! else ! { ! Exception lastException = null; ! java.lang.reflect.Constructor[] cons = c.getConstructors(); ! for (int i = 0; i < cons.length; i++) ! { ! if (cons[i].getParameterTypes().length == args.length) ! { ! // try to instantiate using this constructor ! try ! { ! o = cons[i].newInstance(args); ! break; // if successful, we're done! ! } ! catch (Exception e) ! { ! lastException = e; ! } ! } } ! if (o == null) ! { ! throw new InstantiationException( ! "Unable to construct object of type " + c.getName() ! + " using the supplied arguments: " ! + java.util.Arrays.asList(args).toString()); ! } ! } ! return o; ! } ! private static int getScope (DirectiveBuilder builder, BuildContext bc) throws org.webmacro.engine.BuildException ! { ! int scope = -1; ! for (int i = 0; i < BEAN_SCOPES.length; i++) ! { ! scope = BEAN_SCOPES[i]; ! if (builder.getArg(scope) != null) break; ! } ! return scope; ! } ! public static void init (Broker b) ! { ! // get configuration parameters ! synchronized (b) ! { ! BeanConf bCfg = new BeanConf(b); ! b.setBrokerLocal("BeanDirective.Conf", bCfg); ! Log log = b.getLog("directive"); ! log.debug("BeanDirective initialization - impliedPackages: " + bCfg.impliedPackages); ! log.debug("BeanDirective initialization - allowedPackages: " + bCfg.allowedPackages); ! } ! } ! private Class classForName (String className) throws BuildException ! { ! Class c = null; ! Exception except = null; ! try ! { ! c = _broker.classForName(className); ! } ! catch (Exception cnfe) ! { ! except = cnfe; ! // try with implied packages prepended ! for (int i = 0; i < beanConf.impliedPackages.size(); i++) ! { ! String s = (String) beanConf.impliedPackages.get(i); ! try ! { ! c = _broker.classForName(s + "." + className); ! break; ! } ! catch (Exception cnfe2) ! { ! except = cnfe2; ! } } ! if (c == null) ! { ! throw new BuildException("Unable to load class " + className, except); } ! } ! if (!beanConf.allowedPackages.isEmpty()) ! { ! // check if class is in a permitted package ! String pkg = c.getPackage().getName(); ! if (!beanConf.allowedPackages.contains(pkg)) ! { ! throw new BuildException( ! "You are not permitted to load classes from this package (" + pkg ! + "). Check the \"BeanDirective.AllowedPackages\" parameter in the WebMacro.properties file."); ! } ! } ! return c; ! } } ! class BeanConf ! { ! static Map globalBeans = new HashMap(20); ! Map appBeans = new HashMap(20); ! List impliedPackages; ! List allowedPackages; ! public BeanConf (Broker b) ! { ! String s = b.getSetting("BeanDirective.ImpliedPackages"); ! impliedPackages = Arrays.asList(org.webmacro.servlet.TextTool.split(s, ",")); ! s = b.getSetting("BeanDirective.AllowedPackages"); ! allowedPackages = Arrays.asList(org.webmacro.servlet.TextTool.split(s, ",")); ! } ! public Map getGlobalBeans () ! { ! return globalBeans; ! } ! public Map getAppBeans () ! { ! return appBeans; ! } ! public List getImpliedPackages () ! { ! return impliedPackages; ! } ! public List getAllowedPackages () ! { ! return allowedPackages; ! } } Index: CommentDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/CommentDirective.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CommentDirective.java 11 Jun 2002 17:43:20 -0000 1.6 --- CommentDirective.java 12 Jun 2003 00:47:44 -0000 1.7 *************** *** 23,28 **** package org.webmacro.directive; - import java.io.*; - import org.webmacro.Context; import org.webmacro.FastWriter; --- 23,26 ---- *************** *** 32,64 **** import org.webmacro.engine.BuildException; ! public class CommentDirective extends Directive { ! private static final int COMMENT_BLOCK = 1; ! private static final ArgDescriptor[] ! myArgs = new ArgDescriptor[]{ ! new LiteralBlockArg(COMMENT_BLOCK) ! }; ! private static final DirectiveDescriptor ! myDescr = new DirectiveDescriptor("comment", null, myArgs, null); ! public static DirectiveDescriptor getDescriptor() { ! return myDescr; ! } ! public Object build(DirectiveBuilder builder, ! BuildContext bc) ! throws BuildException { ! return null; ! } ! public void write(FastWriter out, Context context) ! throws PropertyException, IOException { ! } ! public void accept(TemplateVisitor v) { ! v.beginDirective(myDescr.name); ! v.endDirective(); ! } } --- 30,69 ---- import org.webmacro.engine.BuildException; ! import java.io.IOException; ! public class CommentDirective extends Directive ! { ! private static final int COMMENT_BLOCK = 1; ! private static final ArgDescriptor[] ! myArgs = new ArgDescriptor[]{ ! new LiteralBlockArg(COMMENT_BLOCK) ! }; ! private static final DirectiveDescriptor ! myDescr = new DirectiveDescriptor("comment", null, myArgs, null); ! public static DirectiveDescriptor getDescriptor () ! { ! return myDescr; ! } ! public Object build (DirectiveBuilder builder, ! BuildContext bc) ! throws BuildException ! { ! return null; ! } ! public void write (FastWriter out, Context context) ! throws PropertyException, IOException ! { ! } ! ! public void accept (TemplateVisitor v) ! { ! v.beginDirective(myDescr.name); ! v.endDirective(); ! } } Index: CountDirective.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/directive/CountDirective.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CountDirective.java 11 Nov 2002 19:22:36 -0000 1.4 --- CountDirective.java 12 Jun 2003 00:47:44 -0000 1.5 *************** *** 22,28 **** package org.webmacro.directive; ! import org.webmacro.directive.*; ! import org.webmacro.engine.*; ! import org.webmacro.*; import java.io.IOException; --- 22,33 ---- package org.webmacro.directive; ! import org.webmacro.Context; ! import org.webmacro.FastWriter; ! import org.webmacro.Macro; ! import org.webmacro.PropertyException; ! import org.webmacro.engine.Block; ! import org.webmacro.engine.BuildContext; ! import org.webmacro.engine.BuildException; ! import org.webmacro.engine.Variable; import java.io.IOException; *************** *** 34,38 **** * @since 1.1b1 */ ! public class CountDirective extends org.webmacro.directive.Directive { private static final int COUNT_ITERATOR = 1; --- 39,44 ---- * @since 1.1b1 */ ! public class CountDirective extends org.webmacro.directive.Directive ! { private static final int COUNT_ITERATOR = 1; *************** *** 59,63 **** private static final DirectiveDescriptor _desc = new DirectiveDescriptor("count", null, _args, null); ! public static DirectiveDescriptor getDescriptor() { return _desc; } --- 65,70 ---- private static final DirectiveDescriptor _desc = new DirectiveDescriptor("count", null, _args, null); ! public static DirectiveDescriptor getDescriptor () ! { return _desc; } *************** *** 71,78 **** private int _start, _end, _step = 1; ! public Object build(DirectiveBuilder builder, BuildContext bc) throws BuildException { ! try { _iterator = (Variable) builder.getArg(COUNT_ITERATOR, bc); ! } catch (ClassCastException e) { throw new Directive.NotVariableBuildException(_desc.name, e); } --- 78,89 ---- private int _start, _end, _step = 1; ! public Object build (DirectiveBuilder builder, BuildContext bc) throws BuildException ! { ! try ! { _iterator = (Variable) builder.getArg(COUNT_ITERATOR, bc); ! } ! catch (ClassCastException e) ! { throw new Directive.NotVariableBuildException(_desc.name, e); } *************** *** 83,109 **** // attempt to go ahead and force the start, end, and step values into primitive ints ! if (_objStart != null) { ! if (_objStart instanceof Number) { _start = ((Number) _objStart).intValue(); _objStart = null; ! } else if (_objStart instanceof String) { _start = Integer.parseInt((String) _objStart); _objStart = null; } } ! if (_objEnd != null) { ! if (_objEnd instanceof Number) { _end = ((Number) _objEnd).intValue(); _objEnd = null; ! } else if (_objEnd instanceof String) { _end = Integer.parseInt((String) _objEnd); _objEnd = null; } } ! if (_objStep != null) { ! if (_objStep instanceof Number) { _step = ((Number) _objStep).intValue(); _objStep = null; ! } else if (_objStep instanceof String) { _step = Integer.parseInt((String) _objStep); _objStep = null; --- 94,132 ---- // attempt to go ahead and force the start, end, and step values into primitive ints ! if (_objStart != null) ! { ! if (_objStart instanceof Number) ! { _start = ((Number) _objStart).intValue(); _objStart = null; ! } ! else if (_objStart instanceof String) ! { _start = Integer.parseInt((String) _objStart); _objStart = null; } } ! if (_objEnd != null) ! { ! if (_objEnd instanceof Number) ! { _end = ((Number) _objEnd).intValue(); _objEnd = null; ! } ! else if (_objEnd instanceof String) ! { _end = Integer.parseInt((String) _objEnd); _objEnd = null; } } ! if (_objStep != null) ! { ! if (_objStep instanceof Number) ! { _step = ((Number) _objStep).intValue(); _objStep = null; ! } ! else if (_objStep instanceof String) ! { _step = Integer.parseInt((String) _objStep); _objStep = null; *************** *** 114,129 **** } ! public void write(FastWriter out, Context context) throws PropertyException, IOException { ! int start=_start, end=_end, step = _step; Object tmp; // if necessary, do run-time evaluation of our // start, end, and step objects. ! if ( (tmp = _objStart) != null) { while (tmp instanceof Macro) tmp = ((Macro) tmp).evaluate(context); if (tmp != null) start = Integer.parseInt(tmp.toString()); ! else { writeWarning("#count: Starting value cannot be null. Not counting", context, out); return; --- 137,155 ---- } ! public void write (FastWriter out, Context context) throws PropertyException, IOException ! { ! int start = _start, end = _end, step = _step; Object tmp; // if necessary, do run-time evaluation of our // start, end, and step objects. ! if ((tmp = _objStart) != null) ! { while (tmp instanceof Macro) tmp = ((Macro) tmp).evaluate(context); if (tmp != null) start = Integer.parseInt(tmp.toString()); ! else ! { writeWarning("#count: Starting value cannot be null. Not counting", context, out); return; *************** *** 131,140 **** } ! if ( (tmp = _objEnd) != null) { while (tmp instanceof Macro) tmp = ((Macro) tmp).evaluate(context); if (tmp != null) end = Integer.parseInt(tmp.toString()); ! else { writeWarning("#count: Ending value cannot be null. Not counting", context, out); return; --- 157,168 ---- } ! if ((tmp = _objEnd) != null) ! { while (tmp instanceof Macro) tmp = ((Macro) tmp).evaluate(context); if (tmp != null) end = Integer.parseInt(tmp.toString()); ! else ! { writeWarning("#count: Ending value cannot be null. Not counting", context, out); return; *************** *** 142,151 **** } ! if ( (tmp = _objStep) != null) { while (tmp instanceof Macro) tmp = ((Macro) tmp).evaluate(context); if (tmp != null) step = Integer.parseInt(tmp.toString()); ! else { writeWarning("#count: Starting value cannot be null. Not counting", context, out); return; --- 170,181 ---- } ! if ((tmp = _objStep) != null) ! { while (tmp instanceof Macro) tmp = ((Macro) tmp).evaluate(context); if (tmp != null) step = Integer.parseInt(tmp.toString()); ! else ! { writeWarning("#count: Starting value cannot be null. Not counting", context, out); return; *************** *** 153,167 **** } ! 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); } --- 183,204 ---- } ! 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.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DefaultDirective.java 11 Nov 2002 04:26:12 -0000 1.4 --- DefaultDirective.java 12 Jun 2003 00:47:44 -0000 1.5 *************** *** 23,28 **** package org.webmacro.directive; - import java.io.*; - import org.webmacro.*; import org.webmacro.engine.BuildContext; --- 23,26 ---- *************** *** 30,105 **** import org.webmacro.engine.Variable; ! public class DefaultDirective extends Directive { ! private static final int DEFAULT_TARGET = 1; ! private static final int DEFAULT_TO = 2; ! private static final int DEFAULT_RESULT = 3; ! private Variable target; ! private Object result; ! private static final ArgDescriptor[] ! myArgs = new ArgDescriptor[]{ ! new LValueArg(DEFAULT_TARGET), ! new OptionalGro... [truncated message content] |