[CJ-dev] commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet
Brought to you by:
johnqueso
From: <joh...@co...> - 2004-03-12 20:14:43
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2746/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet Modified Files: OplNodeParserPlugin.vm OplNodeParserPlugin.java Log Message: updated to 0.2, made method call parameter generation more robust. Index: OplNodeParserPlugin.vm =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/OplNodeParserPlugin.vm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- OplNodeParserPlugin.vm 10 Mar 2004 21:49:41 -0000 1.3 +++ OplNodeParserPlugin.vm 12 Mar 2004 19:46:56 -0000 1.4 @@ -60,36 +60,38 @@ #set($validator = $method.getNamedParameter("opl.attribute", "validator")) #set($notRequired = $method.getNamedParameter("opl.attribute", "required") == "false") #if($extractor) + #set($ex = ${extractor.replaceAll("@@value", $attrName)}) + #set($call = $plugin.formatInvocation($method, $ex)) #if($notRequired) if($attrName != null){ #end - #set($ex = ${extractor.replaceAll("value", $attrName)}) #if($validator) - if(${validator.replaceAll("value", ${ex})}){ - instance.${method.callSignature.replaceAll("param", $ex)}; + if(${validator.replaceAll("@@value", ${ex})}){ + instance.${call}; } else{ throw new ParseException("Validation of attribute: '${attrName}' failed."); } #else - instance.${method.callSignature.replaceAll("param", $ex)}; + instance.${call}; #end #if($notRequired) } #end #else + #set($call = $plugin.formatInvocation($method, $attrName)) #if($notRequired) if($attrName != null){ #end #if($validator) - if(${validator.replaceAll("value", ${attrName})}){ - instance.${method.callSignature.replaceAll("param", $attrName)}; + if(${validator.replaceAll("@@value", ${attrName})}){ + instance.${call}; } else{ throw new ParseException("Validation of attribute: '${attrName}' failed."); } #else - instance.${method.callSignature.replaceAll("param", $attrName)}; + instance.${call}; #end #if($notRequired) } @@ -121,36 +123,38 @@ #set($validator = $method.getNamedParameter("opl.attribute", "validator")) #set($notRequired = $method.getNamedParameter("opl.attribute", "required") == "false") #if($extractor) + #set($ex = ${extractor.replaceAll("@@value", $attrName)}) + #set($call = $plugin.formatInvocation($method, $ex)) #if($notRequired) if($attrName != null){ #end - #set($ex = ${extractor.replaceAll("value", $attrName)}) #if($validator) - if(${validator.replaceAll("value", ${ex})}){ - instance.${method.callSignature.replaceAll("param", $ex)}; + if(${validator.replaceAll("@@value", ${ex})}){ + instance.${call}; } else{ throw new ParseException("Validation of attribute: '${attrName}' failed."); } #else - instance.${method.callSignature.replaceAll("param", $ex)}; + instance.${call}; #end #if($notRequired) } #end #else + #set($call = $plugin.formatInvocation($method, $attrName)) #if($notRequired) if($attrName != null){ #end #if($validator) - if(${validator.replaceAll("value", ${attrName})}){ - instance.${method.callSignature.replaceAll("param", $attrName)}; + if(${validator.replaceAll("@@value", ${attrName})}){ + instance.${call}; } else{ throw new ParseException("Validation of attribute: '${attrName}' failed."); } #else - instance.${method.callSignature.replaceAll("param", $attrName)}; + instance.${call}; #end #if($notRequired) } @@ -178,10 +182,10 @@ ${childOfTag.getNamedParameter("class")}.class, ${required} ); #if($required) - container${velocityCount}.${childOfTag.getNamedParameter("setter").replaceAll("value", "instance")}; + container${velocityCount}.${childOfTag.getNamedParameter("setter").replaceAll("@@value", "instance")}; #else if(container${velocityCount} != null){ - container${velocityCount}.${childOfTag.getNamedParameter("setter").replaceAll("value", "instance")}; + container${velocityCount}.${childOfTag.getNamedParameter("setter").replaceAll("@@value", "instance")}; } #end Index: OplNodeParserPlugin.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/OplNodeParserPlugin.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- OplNodeParserPlugin.java 10 Mar 2004 21:49:41 -0000 1.3 +++ OplNodeParserPlugin.java 12 Mar 2004 19:46:56 -0000 1.4 @@ -35,6 +35,12 @@ setMultioutput(true); } + public String formatInvocation(Object metadata, String paramClause){ + JavaMethod method = (JavaMethod)metadata; + String formattedSig = method.getCallSignature().replaceAll("\\([^)]+\\)", "(" + paramClause + ")"); + return formattedSig; + } + public boolean shouldGenerate(Object metadata) { JavaClass jc = (JavaClass)metadata; boolean result = jc.getTagByName("opl.parser") != null; |