User: vharcq
Date: 02/04/17 16:02:29
Modified: core/src/xdoclet/tags AbstractProgramElementTagsHandler.java
ClassTagsHandler.java ParameterTagsHandler.java
Log:
Important patch!
I split currentTag in one for class tag and one for method tag
I check if it is set in getTagValue (the biggest method around)
This is to solve in once problems like having
@ejb:permission role-name="a,b" on class and/or method
or having
* @ejb.finder
* signature="Collection findByCode(String code)"
* query="SELECT OBJECT(p) FROM LANGUAGE as p WHERE p.id = ?1"
* @ejb.finder
* signature "Collection findByCode(java.lang.String a, java.lang.String b)"
* query="SELECT OBJECT(p) FROM LANGUAGE as p WHERE p.id = ?1 AND p.id = ?2"
Plus all tags that merge forAllClass and forAllMethod
Plus all tags that have in a forAllMethod on a tag/param a lookup on another
(tag)/(param)
It passes samples and unit tests
Revision Changes Path
1.35 +5 -13
xdoclet/core/src/xdoclet/tags/AbstractProgramElementTagsHandler.java
Index: AbstractProgramElementTagsHandler.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/AbstractProgramElementTagsHandler.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -w -r1.34 -r1.35
--- AbstractProgramElementTagsHandler.java 17 Apr 2002 20:32:20 -0000 1.34
+++ AbstractProgramElementTagsHandler.java 17 Apr 2002 23:02:29 -0000 1.35
@@ -36,7 +36,7 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 15, 2001
- * @version $Revision: 1.34 $
+ * @version $Revision: 1.35 $
*/
public abstract class AbstractProgramElementTagsHandler extends XDocletTagSupport
{
@@ -507,16 +507,7 @@
String tagValue;
- if( getCurrentTag() != null )
- {
- String paramName = attributes.getProperty( "paramName" );
-
- tagValue = getCurrentTag().attributeValue( paramName );
- }
- else
- {
tagValue = getTagValue( attributes, for_type );
- }
String delimiter = attributes.getProperty( "delimiter" );
String skip_str = attributes.getProperty( "skip" );
@@ -619,10 +610,11 @@
for( int i = 0; i < tags.length; i++ )
{
- setCurrentTag( tags[i] );
String m = getTagValue( attributes, for_type );
+ setCurrentMethodTag( tags[i] );
+
if( cat.isDebugEnabled() )
{
cat.debug( "Tag/Param = " + attributes.getProperty(
"tagName" ) + "/" + attributes.getProperty( "paramName" ) + " Value = " + m + "
MatchPattern = " + matchPattern );
@@ -638,7 +630,7 @@
}
}
- setCurrentTag( null );
+ setCurrentMethodTag( null );
}
/**
1.35 +8 -7 xdoclet/core/src/xdoclet/tags/ClassTagsHandler.java
Index: ClassTagsHandler.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/ClassTagsHandler.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -w -r1.34 -r1.35
--- ClassTagsHandler.java 10 Apr 2002 22:21:25 -0000 1.34
+++ ClassTagsHandler.java 17 Apr 2002 23:02:29 -0000 1.35
@@ -24,7 +24,7 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 14, 2001
- * @version $Revision: 1.34 $
+ * @version $Revision: 1.35 $
*/
public class ClassTagsHandler extends AbstractProgramElementTagsHandler
{
@@ -34,6 +34,8 @@
*/
protected final static DateFormat dateFormatter =
DateFormat.getDateTimeInstance();
+ protected final static Calendar now = Calendar.getInstance();
+
/**
* Returns the not-full-qualified name of the current class without the package
* name.
@@ -569,12 +571,13 @@
}
}
- setCurrentTag( tags[i] );
+ setCurrentClassTag( tags[i] );
+ System.out.println( "CT = " + tags[i].value() );
generate( template );
}
- setCurrentTag( null );
+ setCurrentClassTag( null );
matchPattern = null;
}
@@ -706,7 +709,7 @@
}
else
{
- result.append( "XDOCLET " ).append(
DocletTask.XDOCLET_VERSION ).append( PrettyPrintWriter.LINE_SEPARATOR );
+ result.append( spaces ).append( " *
@xdoclet-generated at " ).append( dateFormatter.format( now.getTime() ) ).append(
PrettyPrintWriter.LINE_SEPARATOR );
}
// if( i < class_tags.length - 1 )
@@ -719,9 +722,7 @@
if( include_xdoclet_generated )
{
- Calendar now = Calendar.getInstance();
-
- result.append( spaces ).append( " * @xdoclet-generated at "
).append( dateFormatter.format( now.getTime() ) ).append(
PrettyPrintWriter.LINE_SEPARATOR );
+ result.append( spaces ).append( " * @xdoclet-generated "
).append( PrettyPrintWriter.LINE_SEPARATOR );
}
return result.toString();
1.12 +125 -112 xdoclet/core/src/xdoclet/tags/ParameterTagsHandler.java
Index: ParameterTagsHandler.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/ParameterTagsHandler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- ParameterTagsHandler.java 4 Apr 2002 12:58:08 -0000 1.11
+++ ParameterTagsHandler.java 17 Apr 2002 23:02:29 -0000 1.12
@@ -16,9 +16,10 @@
/**
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Oct 15, 2001
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
-public class ParameterTagsHandler extends AbstractProgramElementTagsHandler {
+public class ParameterTagsHandler extends AbstractProgramElementTagsHandler
+{
/**
* The current method's current parameter. forAllMethodParams sets the value
* while looping over the parameters of current method.
@@ -35,7 +36,6 @@
*/
protected static XTag currentMethodParamTag;
-
/**
* Returns the type of the current method parameter, current method parameter
* is set inside a forAllMethodParams tag in each iteration.
@@ -44,11 +44,11 @@
* @exception XDocletException Description of Exception
* @doc:tag type="content"
*/
- public String methodParamType() throws XDocletException {
+ public String methodParamType() throws XDocletException
+ {
return currentMethodParameter.type().qualifiedName();
}
-
/**
* The <code>methodParamDescription</code> method returns the comment text
* associated with the ParamTag for the current Parameter
@@ -57,8 +57,10 @@
* @exception XDocletException if an error occurs
* @doc:tag type="content"
*/
- public String methodParamDescription() throws XDocletException {
- if (currentMethodParamTag == null) {
+ public String methodParamDescription() throws XDocletException
+ {
+ if( currentMethodParamTag == null )
+ {
return "no description";
}
// end of if ()
@@ -66,7 +68,6 @@
return currentMethodParamTag.value();
}
-
/**
* Returns the name of the current method parameter, current method parameter
* is set inside a forAllMethodParams tag in each iteration.
@@ -75,11 +76,11 @@
* @exception XDocletException Description of Exception
* @doc:tag type="content"
*/
- public String methodParamName() throws XDocletException {
+ public String methodParamName() throws XDocletException
+ {
return currentMethodParameter.name();
}
-
/**
* Iterates over all parameters of current method and evaluates the body of the
* tag for each method.
@@ -88,7 +89,8 @@
* @exception XDocletException Description of Exception
* @doc:tag type="block"
*/
- public void forAllMethodParams(String template) throws XDocletException {
+ public void forAllMethodParams( String template ) throws XDocletException
+ {
forAllParams(getCurrentMethod(), template);
/*
* Parameter[] parameters = getCurrentMethod().parameters();
@@ -110,7 +112,6 @@
*/
}
-
/**
* Iterates over all parameters of current constructor and evaluates the body
* of the tag for each method.
@@ -119,7 +120,8 @@
* @exception XDocletException Description of Exception
* @doc:tag type="block"
*/
- public void forAllConstructorParams(String template) throws XDocletException {
+ public void forAllConstructorParams( String template ) throws XDocletException
+ {
forAllParams(getCurrentConstructor(), template);
/*
* Parameter[] parameters = getCurrentConstructor().parameters();
@@ -131,7 +133,6 @@
*/
}
-
/**
* Iterates over all exceptions thrown by the current method and returns a
* string containing definition of all those parameters.
@@ -140,11 +141,12 @@
* @return Description of the Returned Value
* @exception XDocletException Description of Exception
* @doc:tag type="block"
- * @doc:param name="includeDefinition" optional="true" values="true,false"
- * description="If true then include the parameter type of parameters in
- * the composed string."
+ * @doc:param name="includeDefinition" optional="true"
+ * values="true,false" description="If true then include the parameter
+ * type of parameters in the composed string."
*/
- public String parameterList(Properties attributes) throws XDocletException {
+ public String parameterList( Properties attributes ) throws XDocletException
+ {
String incl = (String)attributes.get("includeDefinition");
XParameter[] parameters = getCurrentMethod().parameters();
@@ -152,20 +154,24 @@
String type = null;
String name = null;
- for (int i = 0; i < parameters.length; i++) {
+ for( int i = 0; i < parameters.length; i++ )
+ {
type = parameters[i].type().qualifiedName();
String methodDimension = parameters[i].dimensionAsString();
name = parameters[i].name();
- if (i > 0) {
+ if( i > 0 )
+ {
st.append(',');
}
- if (incl == null || !incl.equals("false")) {
+ if( incl == null || !incl.equals( "false" ) )
+ {
st.append(type).append(methodDimension).append('
').append(name);
}
- else {
+ else
+ {
st.append(name);
}
}
@@ -173,7 +179,6 @@
return st.toString();
}
-
/**
* Gets the value of the parameter specified by paramName of current tag, and
* assuming the value has the format of a typical method definition extracts of
@@ -183,12 +188,14 @@
* @param template The body of the block tag
* @exception XDocletException Description of Exception
* @doc:tag type="block"
- * @doc:param name="paramName" optional="false" description="The parameter name
- * that its value is used for extracting parameter types out of it."
+ * @doc:param name="paramName" optional="false"
+ * description="The parameter name that its value is used for extracting
+ * parameter types out of it."
*/
- public void forAllParameterTypes(String template, Properties attributes)
throws XDocletException {
+ public void forAllParameterTypes( String template, Properties attributes )
throws XDocletException
+ {
String param_name = attributes.getProperty("paramName");
- String value = getCurrentTag().attributeValue(param_name);
+ String value = getCurrentClassTag().attributeValue( param_name );
String old_token = currentToken;
// findAll(int p1, int p2) -> int p1, int p2
@@ -196,14 +203,16 @@
StringTokenizer st = new StringTokenizer(value, ",", false);
- while (st.hasMoreTokens()) {
+ while( st.hasMoreTokens() )
+ {
currentToken = st.nextToken().trim();
int spacepos_between_type_and_name =
currentToken.lastIndexOf(' ');
spacepos_between_type_and_name =
spacepos_between_type_and_name == -1 ? currentToken.lastIndexOf('\t') :
spacepos_between_type_and_name;
- if (spacepos_between_type_and_name != -1) {
+ if( spacepos_between_type_and_name != -1 )
+ {
currentToken = currentToken.substring(0,
spacepos_between_type_and_name).trim();
}
@@ -213,7 +222,6 @@
currentToken = old_token;
}
-
/**
* Describe what the method does
*
@@ -225,24 +233,29 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for exception
*/
- private void forAllParams(XExecutableMember member, String template) throws
XDocletException {
+ private void forAllParams( XExecutableMember member, String template ) throws
XDocletException
+ {
XParameter[] parameters = member.parameters();
XTag[] paramTags = member.doc().tags("param");
- for (int k = 0; k < parameters.length; k++) {
+ for( int k = 0; k < parameters.length; k++ )
+ {
currentMethodParameter = parameters[k];
currentMethodParamTag = null;
- for (int j = 0; j < paramTags.length; j++) {
+ for( int j = 0; j < paramTags.length; j++ )
+ {
// find @param xxx
String paramTagValue = paramTags[j].value();
StringTokenizer st = new
StringTokenizer(paramTagValue);
String paramTagParam = null;
- if (st.hasMoreTokens()) {
+ if( st.hasMoreTokens() )
+ {
paramTagParam = st.nextToken();
}
- if
(currentMethodParameter.name().equals(paramTagParam)) {
+ if( currentMethodParameter.name().equals(
paramTagParam ) )
+ {
currentMethodParamTag = paramTags[j];
break;
}
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel