Thread: [CJ-dev] commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet
Brought to you by:
johnqueso
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-serv8325/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet Modified Files: OplNodeParserPlugin.java OplNodeParserPlugin.vm OplXsdPlugin.java OplParserLibraryPlugin.java Log Message: fixed small bug in node parser generator to perform null check for non-required attributes 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.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- OplNodeParserPlugin.java 8 Mar 2004 23:06:40 -0000 1.2 +++ OplNodeParserPlugin.java 10 Mar 2004 21:49:41 -0000 1.3 @@ -13,6 +13,8 @@ import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaMethod; +import java.io.File; + /** * @author jdcasey */ @@ -35,7 +37,14 @@ public boolean shouldGenerate(Object metadata) { JavaClass jc = (JavaClass)metadata; - return jc.getTagByName("opl.parser") != null; + boolean result = jc.getTagByName("opl.parser") != null; + if(result){ + System.out.println("Generating file: " + new File(getDestdirFile(), getDestinationFilename(metadata))); + return true; + } + else{ + return false; + } } public boolean shouldGenerateLocalPropertyContainer(Object metadata){ 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.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- OplNodeParserPlugin.vm 8 Mar 2004 23:06:40 -0000 1.2 +++ OplNodeParserPlugin.vm 10 Mar 2004 21:49:41 -0000 1.3 @@ -58,31 +58,42 @@ String $attrName = getAttribute(${plugin.getAttributeConstant($method)}, info, ${method.getNamedParameter("opl.attribute", "resolve-value")}); #set($extractor = $method.getNamedParameter("opl.attribute", "extractor")) #set($validator = $method.getNamedParameter("opl.attribute", "validator")) + #set($notRequired = $method.getNamedParameter("opl.attribute", "required") == "false") #if($extractor) + #if($notRequired) if($attrName != null){ - #set($ex = ${extractor.replaceAll("value", $attrName)}) + #end + #set($ex = ${extractor.replaceAll("value", $attrName)}) #if($validator) if(${validator.replaceAll("value", ${ex})}){ instance.${method.callSignature.replaceAll("param", $ex)}; } else{ - throw new ParseException("Validation of ${attrName} failed."); + throw new ParseException("Validation of attribute: '${attrName}' failed."); } #else instance.${method.callSignature.replaceAll("param", $ex)}; #end + #if($notRequired) } + #end #else + #if($notRequired) + if($attrName != null){ + #end #if($validator) if(${validator.replaceAll("value", ${attrName})}){ instance.${method.callSignature.replaceAll("param", $attrName)}; } else{ - throw new ParseException("Validation of ${attrName} failed."); + throw new ParseException("Validation of attribute: '${attrName}' failed."); } #else instance.${method.callSignature.replaceAll("param", $attrName)}; #end + #if($notRequired) + } + #end #end } catch(ParseException e){ @@ -105,34 +116,45 @@ #if($method.getNamedParameter("opl.attribute", "before-children") == "false") try{ #set($attrName = $method.getNamedParameter("opl.attribute", "name")) - String $attrName = getAttribute(${plugin.getAttributeConstant($method)}, info, $method.getNamedParameter("opl.attribute", "resolve-value")); + String $attrName = getAttribute(${plugin.getAttributeConstant($method)}, info, ${method.getNamedParameter("opl.attribute", "resolve-value")}); #set($extractor = $method.getNamedParameter("opl.attribute", "extractor")) #set($validator = $method.getNamedParameter("opl.attribute", "validator")) + #set($notRequired = $method.getNamedParameter("opl.attribute", "required") == "false") #if($extractor) + #if($notRequired) if($attrName != null){ - #set($ex = ${extractor.replaceAll("value", $attrName)}) + #end + #set($ex = ${extractor.replaceAll("value", $attrName)}) #if($validator) if(${validator.replaceAll("value", ${ex})}){ instance.${method.callSignature.replaceAll("param", $ex)}; } else{ - throw new ParseException("Validation of ${attrName} failed."); + throw new ParseException("Validation of attribute: '${attrName}' failed."); } #else instance.${method.callSignature.replaceAll("param", $ex)}; #end + #if($notRequired) } + #end #else + #if($notRequired) + if($attrName != null){ + #end #if($validator) if(${validator.replaceAll("value", ${attrName})}){ instance.${method.callSignature.replaceAll("param", $attrName)}; } else{ - throw new ParseException("Validation of ${attrName} failed."); + throw new ParseException("Validation of attribute: '${attrName}' failed."); } #else instance.${method.callSignature.replaceAll("param", $attrName)}; #end + #if($notRequired) + } + #end #end } catch(ParseException e){ Index: OplXsdPlugin.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/OplXsdPlugin.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OplXsdPlugin.java 8 Mar 2004 14:36:34 -0000 1.1 +++ OplXsdPlugin.java 10 Mar 2004 21:49:41 -0000 1.2 @@ -8,6 +8,8 @@ import com.thoughtworks.qdox.model.JavaClass; +import java.io.File; + /** * @author jdcasey */ @@ -57,7 +59,14 @@ */ public boolean shouldGenerate(Object metadata) { JavaClass jc = (JavaClass)metadata; - return jc.getTagByName("opl.parser") != null; + boolean result = jc.getTagByName("opl.parser") != null; + if(result){ + System.out.println("Generating file: " + new File(getDestdirFile(), libraryName + ".xsd")); + return true; + } + else{ + return false; + } } /** Override to pre-set the file to generate. Index: OplParserLibraryPlugin.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/OplParserLibraryPlugin.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OplParserLibraryPlugin.java 8 Mar 2004 14:36:34 -0000 1.1 +++ OplParserLibraryPlugin.java 10 Mar 2004 21:49:41 -0000 1.2 @@ -7,6 +7,8 @@ import com.thoughtworks.qdox.model.JavaClass; +import java.io.File; + /** * @author jdcasey */ @@ -56,7 +58,14 @@ */ public boolean shouldGenerate(Object metadata) { JavaClass jc = (JavaClass)metadata; - return jc.getTagByName("opl.parser") != null; + boolean result = jc.getTagByName("opl.parser") != null; + if(result){ + System.out.println("Generating file: " + new File(getDestdirFile(), libraryName + ".opl")); + return true; + } + else{ + return false; + } } /** Override to pre-set the file to generate. |