Update of
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-qtags/src/main/java/org/xdoclet/plugin/qtags/impl
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30108/plugin-qtags/src/main/java/org/xdoclet/plugin/qtags/impl
Modified Files:
QTagImplPlugin.vm
Log Message:
Support to QTags to return array types:
Tag values will be running through a StringTokenizer.
Each array value will be validated through if used it @qtags.allowed-value.
The StringTokenizer delimiter is by default "," but can also be ";" - This can
be set using @qtags.list-token.
Note: Before @qtags.default was not being verified against a valid value set by
@qtags.allowed-value.
Current generated tag impl changed this - The default value is set before
values validation.
Index: QTagImplPlugin.vm
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-qtags/src/main/java/org/xdoclet/plugin/qtags/impl/QTagImplPlugin.vm,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** QTagImplPlugin.vm 27 Oct 2004 08:51:49 -0000 1.14
--- QTagImplPlugin.vm 21 Aug 2005 13:44:30 -0000 1.15
***************
*** 5,20 ****
public static final String NAME =
"${plugin.getQTagUtils().getDocletTagName($class)}";
private static final java.util.List ALLOWED_PARAMETERS =
java.util.Arrays.asList( new String[] {
! #foreach($method in ${class.getMethods(true)})
!
#if(!$method.parentClass.fullyQualifiedName.equals('com.thoughtworks.qdox.model.DocletTag'))
! "${plugin.getQTagUtils().getDocletTagParameterName($method)}",
! #end
! #end
! ""
});
private static final java.util.List ALLOWED_VALUES =
java.util.Arrays.asList( new String[] {
! #foreach ( $tag in $class.getTagsByName('qtags.allowed-value') )
! "${tag.value}",
! #end
""
});
--- 5,18 ----
public static final String NAME =
"${plugin.getQTagUtils().getDocletTagName($class)}";
private static final java.util.List ALLOWED_PARAMETERS =
java.util.Arrays.asList( new String[] {
! #foreach($method in ${plugin.getQTagUtils().getMethods($class)})
! "${plugin.getQTagUtils().getDocletTagParameterName($method)}",
! #end
! ""
});
private static final java.util.List ALLOWED_VALUES =
java.util.Arrays.asList( new String[] {
! #foreach ( $tag in $class.getTagsByName('qtags.allowed-value') )
! "${tag.value}",
! #end
""
});
***************
*** 23,35 ****
}
! #foreach($method in ${class.getMethods(true)})
!
#if(!$method.parentClass.fullyQualifiedName.equals('com.thoughtworks.qdox.model.DocletTag'))
! #set( $checkParameters = 'true' )
public $method.getDeclarationSignature(true) {
! #if($method.getTagByName("qtags.required"))
! boolean required = true;
! #else
! boolean required = false;
! #end
String result =
getNamedParameter("${plugin.getQTagUtils().getDocletTagParameterName($method)}");
if(required && result == null) {
--- 21,32 ----
}
! #foreach($method in ${plugin.getQTagUtils().getMethods($class)})
! #set( $checkParameters = 'true' )
public $method.getDeclarationSignature(true) {
! #if($method.getTagByName("qtags.required"))
! boolean required = true;
! #else
! boolean required = false;
! #end
String result =
getNamedParameter("${plugin.getQTagUtils().getDocletTagParameterName($method)}");
if(required && result == null) {
***************
*** 37,126 ****
}
! #if($method.getTagByName("qtags.allowed-value"))
! if(result != null) {
! if( !(false #foreach($tag in
$method.getTagsByName("qtags.allowed-value"))||
result.equals("$tag.value")#end) ) {
! // todo we should say what file and line number too
!
bomb("${plugin.getQTagUtils().getDocletTagParameterName($method)}=\"" + result
+ "\" is an invalid parameter value.");
! }
}
! #end
!
! #if($method.getTagByName("qtags.default"))
! if(result == null) {
! result = "${method.getTagByName("qtags.default").value}";
! }
! #end
!
! #if($method.returns.value == "java.lang.Boolean")
! if(result != null) {
! return Boolean.valueOf(result);
! } else {
! return null;
! }
! #elseif($method.returns.value == "boolean")
! return Boolean.valueOf(result).booleanValue();
! #elseif($method.returns.value == "int")
! if (result != null) {
! try {
! return Integer.decode(result).intValue();
! } catch(NumberFormatException nfe) {
!
bomb("${plugin.getQTagUtils().getDocletTagParameterName($method)}=\"" + result
+ "\" is not valid integer");
! throw nfe;
! }
! } else {
! return 0;
! }
! #elseif($method.returns.value == "java.lang.Integer")
! if(result != null) {
! try {
! return Integer.decode(result);
! } catch(NumberFormatException nfe) {
!
bomb("${plugin.getQTagUtils().getDocletTagParameterName($method)}=\"" + result
+ "\" is not valid integer");
! throw nfe;
! }
! } else {
! return null;
! }
! #else
! return result;
! #end
}
- #end
#end
protected void validateLocation() {
! #if($plugin.getQTagUtils().disallowedOn($class, "class"))
! if(isOnClass) {
! bomb("is not allowed on classes");
! }
! #end
! #if($plugin.getQTagUtils().disallowedOn($class, "field"))
! if(isOnField) {
! bomb("is not allowed on fields");
! }
! #end
! #if($plugin.getQTagUtils().disallowedOn($class, "constructor"))
! if(isOnConstructor) {
! bomb("is not allowed on constructors");
! }
! #end
! #if($plugin.getQTagUtils().disallowedOn($class, "method"))
! if(isOnMethod) {
! bomb("is not allowed on methods");
! }
! #end
// check uniqueness
!
! #if ( $class.getTagByName('qtags.once') )
! if(getContext().getTagsByName(NAME).length > 1) {
! bomb("is allowed only once");
! }
! #end
// warn deprecation
! #if ( $class.getTagByName('qtags.deprecated') )
! System.err.println("@" + getName() + ":" + getValue());
! #end
// check for allowed values for whole tag
--- 34,138 ----
}
! #if($method.returns.isArray())
! ${method.returns.value}[] retVal = null;
! #elseif($method.returns.value == "boolean")
! $method.returns.value retVal = false;
! #elseif($method.returns.value == "int")
! $method.returns.value retVal = 0;
! #else
! $method.returns.value retVal = null;
! #end
!
! #if($method.getTagByName("qtags.default"))
! if(result == null) {
! result = "${method.getTagByName("qtags.default").value}";
}
! #end
!
! if (result != null) {
! #if($method.returns.isArray())
! java.util.StringTokenizer strTok = new
java.util.StringTokenizer(result,
"${plugin.getQTagUtils().getTokenizer($method)}");
! retVal = new
${method.returns.value}[strTok.countTokens()];
! int idx = 0;
! String token;
! #set( $setVarName = 'retVal[idx++]' )
! #set( $sourceVarName = 'token' )
! #else
! #set( $setVarName = 'retVal' )
! #set( $sourceVarName = 'result' )
! #end
! #if($method.returns.isArray())
! while (strTok.hasMoreTokens()) {
! $sourceVarName = strTok.nextToken();
! #end
! #if($method.getTagByName("qtags.allowed-value"))
! if( !(false #foreach($tag in
$method.getTagsByName("qtags.allowed-value"))||
${sourceVarName}.equals("$tag.value")#end) ) {
! // todo we should say what file and line number too
!
bomb("${plugin.getQTagUtils().getDocletTagParameterName($method)}=\"" +
${sourceVarName} + "\" is an invalid parameter value.");
! }
! #end
! #if($method.returns.value == "java.lang.Boolean")
! $setVarName = Boolean.valueOf(${sourceVarName});
! #elseif($method.returns.value == "boolean")
! $setVarName =
Boolean.valueOf(${sourceVarName}).booleanValue();
! #elseif($method.returns.value == "int")
! try {
! $setVarName =
Integer.decode(${sourceVarName}).intValue();
! } catch(NumberFormatException nfe) {
!
bomb("${plugin.getQTagUtils().getDocletTagParameterName($method)}=\"" +
${sourceVarName} + "\" is not valid integer");
! throw nfe;
! }
! #elseif($method.returns.value == "java.lang.Integer")
! try {
! $setVarName = Integer.decode(${sourceVarName});
! } catch(NumberFormatException nfe) {
!
bomb("${plugin.getQTagUtils().getDocletTagParameterName($method)}=\"" +
${sourceVarName} + "\" is not valid integer");
! throw nfe;
! }
! #else
! $setVarName = ${sourceVarName};
! #end
! #if($method.returns.isArray())
! }
! #end
! }
!
! return retVal;
}
#end
protected void validateLocation() {
! #if($plugin.getQTagUtils().disallowedOn($class, "class"))
! if(isOnClass) {
! bomb("is not allowed on classes");
! }
! #end
! #if($plugin.getQTagUtils().disallowedOn($class, "field"))
! if(isOnField) {
! bomb("is not allowed on fields");
! }
! #end
! #if($plugin.getQTagUtils().disallowedOn($class, "constructor"))
! if(isOnConstructor) {
! bomb("is not allowed on constructors");
! }
! #end
! #if($plugin.getQTagUtils().disallowedOn($class, "method"))
! if(isOnMethod) {
! bomb("is not allowed on methods");
! }
! #end
// check uniqueness
! #if ( $class.getTagByName('qtags.once') )
! if(getContext().getTagsByName(NAME).length > 1) {
! bomb("is allowed only once");
! }
! #end
// warn deprecation
! #if ( $class.getTagByName('qtags.deprecated') )
! System.err.println("@" + getName() + ":" + getValue());
! #end
// check for allowed values for whole tag
***************
*** 128,133 ****
bomb( "\"" + getValue() +"\" is not a valid value. Allowed values
are #foreach($tag in $class.getTagsByName('qtags.allowed-value'))
\"${tag.value}\"\n#end");
}
! #if ( $checkParameters )
!
// Verify that all parameters are known.
final java.util.Collection parameterNames =
getNamedParameterMap().keySet();
--- 140,144 ----
bomb( "\"" + getValue() +"\" is not a valid value. Allowed values
are #foreach($tag in $class.getTagsByName('qtags.allowed-value'))
\"${tag.value}\"\n#end");
}
! #if ( $checkParameters )
// Verify that all parameters are known.
final java.util.Collection parameterNames =
getNamedParameterMap().keySet();
***************
*** 138,148 ****
}
}
! #end
// Get all the parameters to validate their contents
! #foreach($method in ${class.methods})
! ${method.callSignature};
! #end
!
}
}
\ No newline at end of file
--- 149,158 ----
}
}
! #end
// Get all the parameters to validate their contents
! #foreach($method in ${plugin.getQTagUtils().getMethods($class)})
! ${method.callSignature};
! #end
}
}
\ No newline at end of file
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
xdoclet-plugins-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits