Update of /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tagshandler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1456/xdoclet/core/src/xdoclet/tagshandler
Modified Files: ClassTagsHandler.java AbstractProgramElementTagsHandler.java Log Message: added new tag setting a variable usable inside the tag's body; first real-world implementation used in ClassTagsHandler and struts_config_xml.xdt when fixing XDT-26, XDT-715 and XDT-740 Index: ClassTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tagshandler/ClassTagsHandler.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** ClassTagsHandler.java 26 Mar 2005 10:24:36 -0000 1.25 --- ClassTagsHandler.java 9 Jun 2005 11:22:53 -0000 1.26 *************** *** 126,129 **** --- 126,161 ---- /** + * Sets the value of variable to some attribute of a class tag, if any. The variable's value is available inside the + * body of this tag via [EMAIL PROTECTED] AbstractProgramElementTagsHandler#variable()}. + * + * @param template The body of the block tag + * @param attributes The attributes of the template tag + * @exception XDocletException Description of Exception + * @doc.tag type="content" + * @doc.param name="tagName" optional="false" description="The tag name." + * @doc.param name="paramName" description="The parameter name. If not specified, then the raw + * content of the tag is returned." + * @doc.param name="paramNum" description="The zero-based parameter number. It's used if the user + * used the space-separated format for specifying parameters." + * @doc.param name="values" description="The valid values for the parameter, comma separated. An + * error message is printed if the parameter value is not one of the values." + * @doc.param name="default" description="The default value is returned if parameter not specified + * by user for the tag." + * @doc.param name="superclasses" values="true,false" description="If true then traverse + * superclasses also, otherwise look up the tag in current concrete class only." + * @doc.param name="mandatory" values="true,false" description="Generate an error if parameter not + * specified by user for the tag." + */ + public void setVariableToClassTagValue(String template, Properties attributes) throws XDocletException + { + String classTagValue = classTagValue(attributes); + + if (classTagValue != null) { + attributes.setProperty("value", classTagValue); + super.setVariable(template, attributes); + } + } + + /** * Iterates over all tags named according to tagName in a non-duplicated manner. The paramName parameter specifies * the tag parameter that should be unique during the iteration. Duplicated tags will generate a warning message. *************** *** 496,499 **** --- 528,560 ---- /** + * Evaluates the body if value for the class tag equals the variable set using [EMAIL PROTECTED] #setVariable(String, + * Properties)}. + * + * @param template The body of the block tag + * @param attributes The attributes of the template tag + * @exception XDocletException Description of Exception + * @doc.tag type="block" + * @doc.param name="tagName" optional="false" description="The tag name." + * @doc.param name="paramName" description="The parameter name. If not specified, then the raw + * content of the tag is returned." + * @doc.param name="paramNum" description="The zero-based parameter number. It's used if the user + * used the space-separated format for specifying parameters." + * @doc.param name="evaluateWhenNotPresent" values="true,false" description="If true the body is + * evaluated even when the specified tag is not found, otherwise it's skipped." + */ + public void ifClassTagValueEqualsVariable(String template, Properties attributes) throws XDocletException + { + boolean evaluateWhenNotPresent = Boolean.valueOf(attributes.getProperty("evaluateWhenNotPresent", "false")).booleanValue(); + + if (evaluateWhenNotPresent && !hasTag(attributes, FOR_CLASS)) { + generate(template); + } + else { + attributes.setProperty("value", variable()); + ifClassTagValueEquals(template, attributes); + } + } + + /** * Evaluates the body if value for the class tag not equals the specified value. * *************** *** 517,520 **** --- 578,610 ---- /** + * Evaluates the body if value for the class tag not equals the variable set using [EMAIL PROTECTED] #setVariable(String, + * Properties)}. + * + * @param template The body of the block tag + * @param attributes The attributes of the template tag + * @exception XDocletException Description of Exception + * @doc.tag type="block" + * @doc.param name="tagName" optional="false" description="The tag name." + * @doc.param name="paramName" description="The parameter name. If not specified, then the raw + * content of the tag is returned." + * @doc.param name="paramNum" description="The zero-based parameter number. It's used if the user + * used the space-separated format for specifying parameters." + * @doc.param name="evaluateWhenNotPresent" values="true,false" description="If true the body is + * evaluated even when the specified tag is not found, otherwise it's skipped." + */ + public void ifClassTagValueNotEqualsVariable(String template, Properties attributes) throws XDocletException + { + boolean evaluateWhenNotPresent = Boolean.valueOf(attributes.getProperty("evaluateWhenNotPresent", "false")).booleanValue(); + + if (evaluateWhenNotPresent && !hasTag(attributes, FOR_CLASS)) { + generate(template); + } + else { + attributes.setProperty("value", variable()); + ifClassTagValueNotEquals(template, attributes); + } + } + + /** * Iterates over all class tags with the specified tagName and evaluates the body of the tag for each class tag. * Index: AbstractProgramElementTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tagshandler/AbstractProgramElementTagsHandler.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** AbstractProgramElementTagsHandler.java 22 Feb 2005 23:57:25 -0000 1.17 --- AbstractProgramElementTagsHandler.java 9 Jun 2005 11:22:53 -0000 1.18 *************** *** 40,44 **** /** ! * Template can use matchPattern as a place where they can put volatile variable. You can set the value somewhere in * the template and later use the value. */ --- 40,44 ---- /** ! * Template can use matchPattern as a place where it can put volatile variable. You can set the value somewhere in * the template and later use the value. */ *************** *** 46,49 **** --- 46,55 ---- /** + * Template can use variable as a place where it can put some value. The variable is available inside the body of + * the [EMAIL PROTECTED] #setVariable(String, Properties)} tag. + */ + protected static String variable; + + /** * Returns the not-full-qualified name of the specified class without the package name. * *************** *** 259,262 **** --- 265,284 ---- /** + * Sets the value of variable to some value. The value is available inside the body of this tag + * + * @param template The body of the block tag + * @param attributes The attributes of the template tag + * @exception XDocletException Description of Exception + * @doc.tag type="block" + * @doc.param name="value" optional="false" description="The new value for variable." + */ + public void setVariable(String template, Properties attributes) throws XDocletException + { + variable = attributes.getProperty("value"); + generate(template); + variable = null; + } + + /** * Returns the value of match variable. Match variable serves as a variable for templates, you set it somewhere in * template and look it up somewhere else in template. *************** *** 272,275 **** --- 294,310 ---- /** + * Returns the value of variable. Variable serves as a variable for templates, you set it somewhere in template + * (using [EMAIL PROTECTED] #setVariable(String, Properties)}) and look it up somewhere else in template. + * + * @return value of variable + * @exception XDocletException Description of Exception + * @doc.tag type="content" + */ + public String variable() throws XDocletException + { + return variable; + } + + /** * Returns current token inside forAllClassTagTokens. * ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput a projector? How fast can you ride your desk chair down the office luge track? If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20 _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel